Different codes for different - looking of table (but the same memory-wise)

(I've posted something similar here as well, but it's kind of emergency):
http://www.Java-forums.org/advanced-Java/40756-HashMap-treating-isomorphic-but-different-objects-same-key.html)

Hi all

I am trying to program the Reversi game on my computer and I represent the game like a lookup table tree using a hash table.
Any available to the Commission is represented as an int. [8] [8]. The hash table takes a configuration of the Board of Directors as a key, and is meant to restore an object that contains information about the possible move.

But I have a problem. Suppose I have a Council (4 x 4 for readability):

Code:
Board of Directors of int [] [] = {{0,0,0,0}, {0,0,0,0}, {0,0,0,0}, {0,0,0,0}};

And suppose that it gives a hash code of say "1607178090".

Then, when I change the Council;
Board = {{0,0,0,0}, {0,0,0,0}, {1,1,1,1}, {1,1,1,1}};
I want the hash to be different code, then my hashMap will recognize it as a different Board.


---

I tried to make a Matrix object and dominant equals and hashCode, but I'm not sure what to change. The Java API says that the hash code for the tables is based on the content, even if the following code renders the same code to hash twice. I don't really understand this:
int [] a1 = {0,1,2};
System.out.println (a1.getHash ());
A1 [0] = 1;
System.out.println (a1.getHash ());




Moreover, my Matrix class is:
to import java.util.Arrays;

public class {Matrix
public int [] [] Council;
public matrix()) {}
}

{public matrix (int [] [] b)
Board = b;
}

@Override
public int hashCode() {}
first final int = 31;
int result = 1;
System.out.println ("based hash code calculation on :"); ")
first = result * result + Arrays.hashCode (board);
for (int c = 0; c < board.length; c ++) {}
for (int r = 0; r < board.length; r ++) {}
System.out.Print(""+Board[c][r]+"");
}
System.out.println ();
}
System.out.println ("return" + result);
return the result;
}

@Override
public boolean equals (Object obj) {}
If (this is obj)
Returns true;
If (obj is nothing)
Returns false;
If (getClass()! = obj.getClass ())
Returns false;
Matrix other obj = (matrix);
If (!.) Arrays.Equals (Council, other.board))
Returns false;
Returns true;
}
}

Published by: 845707 on 19 / mrt / 2011 02:20

845707 wrote:
I don't really understand this:
int [] a1 = {0,1,2};
System.out.println (a1.getHash ());
A1 [0] = 1;
System.out.println (a1.getHash ());

Me neither does table have a method called "getHash();" these days?
In case you meant hashCode(), what you call it is hashCode() of the object, which would remain the same for the object during its lifetime.

In your example code you use correctly Arrays.hashCode (), then why did you write an example that does not represent your actual code?

Tags: Java

Similar Questions

  • Different look of two of the same videos after having copied them.

    Hi community support.

    I copied a video (screen 1) a difference in sequence so that I can change it without losing the original that I created.  On the video copy I made my changes, and when I visited the new sequence of the video I noticed the video had black areas at the top and bottom (Screen Shot 2).  Why is this happen and how can I solve this problem.  I also noticed that the GSM logos have been distorted, I don't know how fix the logos, but also curious why it happened also.  Thank you for your time and help in answering this question.

    Randall

    There is a difference between the sequence the sequence #1 and #2 parameters.

    Access your source sequence, where you have copied the clip. Click anywhere in the timeline panel. Type the command + 0 {zero} to display the sequence settings.

    Check the dimensions of your pixels and the framework.

    Now pass your new sequence, where you have pasted clips and do the same for the new sequence. Compare the results.

    The screenshot you posted, it seems that your original sequence could have an incorrect Pixel Aspect Ratio.

    Unless you have specific reason besides, video HD should always have a Square Pixel Aspect Ratio:

    MtD

  • Import an image with a different top-level folder but the same folder structure

    Hi all

    I am trying to write a script that can add a picture to a location to save the current image.

    So, if the file is hosted at:

    \\10.41.15.75\Photostudio_Primary\ON01\ON012954\ON01386005\stills\054.jpg

    I would like the script to run on the image and the image is added to

    \\10.41.15.75\Photostudio_Secondary\ON01\ON012954\ON01386005\stills\054.jpg


    the top layer.


    I looked in help to find and replace functions, but I got nowhere, someone at - it advice?


    Thank you!

    It work?

    2015, use it at your own risk.

    #target photoshop

    If (app.documents.length > 0) {}

    myDocument var = app.activeDocument;

    var theFiie = String (myDocument.fullName) replace ("Photostudio_Primary", "Photostudio_Secondary");

    If (queue (theFiie) .exists == true) {}

    var theLayer = placeScaleRotateFile (theFiie, 0, 0, 100, 100, 0, true);

    }

    };

    place.

    function placeScaleRotateFile (file, x_offset, decalage_y, theXScale, theYScale, theAngle, related) {}

    // =======================================================

    var idPlc = charIDToTypeID ("Plc");

    var desc5 = new ActionDescriptor();

    var idnull = charIDToTypeID ("null");

    Desc5.putPath (idnull, new (file));

    var idFTcs = charIDToTypeID ("CIE");

    var idQCSt = charIDToTypeID ("QCSt");

    var idQcsa = charIDToTypeID ("Qcsa");

    Desc5.putEnumerated (idFTcs, idQCSt, idQcsa);

    var idOfst = charIDToTypeID ("Ofst");

    var desc6 = new ActionDescriptor();

    var idHrzn = charIDToTypeID ("Hrzn");

    var idPxl = charIDToTypeID ("#Pxl");

    desc6.putUnitDouble (idHrzn, idPxl, x_offset);

    var idVrtc = charIDToTypeID ("Vrtc");

    var idPxl = charIDToTypeID ("#Pxl");

    desc6.putUnitDouble (idVrtc, idPxl, decalage_y);

    var idOfst = charIDToTypeID ("Ofst");

    Desc5.putObject (idOfst, idOfst, desc6);

    var idWdth = charIDToTypeID ("Wdth");

    var idPrc = charIDToTypeID ("#Prc");

    Desc5.putUnitDouble (idWdth, idPrc, theYScale);

    var idHght = charIDToTypeID ("Hght");

    var idPrc = charIDToTypeID ("#Prc");

    Desc5.putUnitDouble (idHght, idPrc, theXScale);

    var idAngl = charIDToTypeID ("Marko");

    Bryan var = charIDToTypeID ("#Ang");

    Desc5.putUnitDouble (idAngl, Bryan, theAngle);

    If (related == true) {}

    var idLnkd = charIDToTypeID ("Lnkd");

    Desc5.putBoolean (idLnkd, true);

    };

    executeAction (idPlc, desc5, DialogModes.NO);

    // =======================================================

    Return app.activeDocument.activeLayer;

    };

  • Sales order form, line status code is displayed as "WITHDRAWN". but the same code appears as "AWAITING_SHIPPING" for the same line in the database. can you please explain, where the value in frontend comes? It differs from the flow_status_code in oe_or

    Sales order form, line status code is displayed as "WITHDRAWN". but the same code appears as "AWAITING_SHIPPING" for the same line in the database.

    Where the value in the frontend is filling?

    It differs from the flow_status_code in oe_order_lines_all?

    Thanks for the correction.

    He slipped right out of my mind!

    Here is a detailed explanation of this case:

    Status of orders picked and picked partial

    Kind regards

    Bashar

  • Insertion of records in two different tables at the same time?

    Hello everyone, I have question about inserting records in two different tables at the same time, I'm looking for is by the way a unique id, which is created in the first statement insert to the second insert statement. Example of this problem:

    < cfquery name = "addRecords1" datasource = 'test' >

    Insert Into Table1 (name, Date, age)

    Values (< cfqueryparam cfsqltype = "cf_sql_char" value = "#arguments.) "Name # ' >.

    < cfqueryparam cfsqltype = 'cf_sql_date' value = '#arguments. "Date # ' >.

    < cfqueryparam cfsqltype = "cf_sql_int" value = "#arguments. Age #"(>); "

    Select SCOPE_IDENTITY() as RecID;

    < / cfquery >

    < cfquery name = "addRecords2" datasource = 'test' >

    Insert into Table2(Company,City,Date,ID)

    Values (< cfqueryparam cfsqltype = "cf_sql_char" value = "#arguments.Company #" >,)

    < cfqueryparam cfsqltype = "cf_sql_char" value = "" #City # ">,"

    < cfqueryparam cfsqltype = 'cf_sql_date' value = "" #Date # ">,"

    ( < cfqueryparam cfsqltype = "cf_sql_int" value = "How to pass RecID to insert in this table?" >).

    < / cfquery >

    In this example, I'm inserting records in table 1 and creation of IDENTITY SCOPE as RecId. I would like to pass this id and insert it in my table 2. This Id, I'll use in my second table as an identifier. If anyone knows anything about this please let me know. Thank you.

    );
    

    QueryName - DOT - ColumnName, so it should be:

    );
    

    HTH,

    ^_^

  • can I display different tables at the same time?

    Hi all

    It is probably a newbie question, but is it possible to display different tables at the same time? I use SQL Developer 1.5.5 and I seem to be unable to display several tables at the same time, whenever I chose to open another table, the old table disappears. In other words, the Bulletin Board only switches to your new choice in the table list navigation. Any ideas anyone?

    Kind regards
    WF

    Menu item "Tools-> Preferences-> database-> ObjectViewer Parameters"; Make sure that "automatically freeze object viewer Windows" is checked.

    HTH.

    Hrsg.:.

  • Why I get two files with different names but the same image when I save in 2015 CC Photoshop?

    Why I get two files with different names but the same image when I save in 2015 CC Photoshop?

    Try resetting the PS preferences - Preferences in Photoshop

    ~ Rohit

  • How to find the same column name in different tables in the same schema

    Hello

    I find the 'ename' column name in different tables in the same schema.

    Thank you
    Nr

    Hello

    Try this query

    Select column_name, table_name from user_tab_columns where column_name = 'ENAME ';

    Award points and end the debate, if your question is answered or mark if she was...

    Kind regards

    Lacouture.

  • I have House part for my iPhone and apple TV, but the iPhone libraries are not listed under computers on Apple TV.  I don't see libraries for my Mac.  I use the same ID across the three devices apple

    I have House part for my iPhone and apple TV, but the iPhone libraries are not listed under computers on Apple TV.  I don't see libraries for my Mac.  I use the same identifier apple through the three devices. I have an iPhone 6 more working 9.0. The devices are all on the same home network running.

    You can't share a library that is located on an iPhone, iPod or iPad with other devices. You can only share a library that is located on a Mac or a PC with other devices. On other devices, iPhone, iPod and iPad for example, you then activate home sharing to connect to the shared library.

  • McAfree and Avast, do do different things or r they the same.

    they do different things or r they the same.
    I have them both running
    I hope that's not causing internet problems

    Do not use both. Uninstall one. You only need an AV program

  • I own a license for adobe acrobat 9 standard, but the CD is broken. How can I download a copy?

    I own a license for adobe acrobat 9 standard, but the CD is broken. How can I download a copy?

    Hi Miguel,.

    Please download it here: https://helpx.adobe.com/acrobat/kb/acrobat-8-9-product-downloads.html

    Kind regards

    Rahul

  • I have DC Acrobat and run it on Windows 7.  I have a Brother printer.  I downloaded the new drivers last night, but the same problem occurs: when I try to print, I get a message in a dialog box, "the cocument could is allowed.  When I click on

    I have DC Acrobat and run it on Windows 7.  I have a Brother printer.  I downloaded the new drivers last night, but the same problem occurs: when I try to print, I get a message in a dialog box, "the cocument could is allowed.  When I click on out of the box with this message, I get a different dialog box including the message says "it has not chosen to print pages".  Any suggestion would be appreciated.

    The way I got it to print has been:

    Without opening the program, in the list of applications, move on to Adobe Reader and right click, select Properties.

    Go to the compatibility and click 'run as Admin '.  Reopen the application and all prints for me now.

    (This can only work with your personal computer if?)

  • At all indexes on tables of the same value in the structure of the event

    Hello

    I have a panel with the four bays and I use a structure of the event.

    Now, I want that change of the index of array_1 also affects the index of 3 other tables at the same index.

    But there is only a property "value Exchange" and no property 'index-change' in the properties of the table.

    So I read the 'index' property and write in the other table.

    But: It seems as if I have to do so within the period of waiting-section of the structure of the event.

    Is there another way to do this?

    Thanks for help

    You can use the mouse event on each table to detec the event (of course, that will attract not only a change of index, but I don't think you care too) and then use the 'values of the indices' property on all the table to set.

    See annex VI (LV2012), hope this helps

  • Update two tables at the same time?

    Hi, I'm having some trouble finding how to create a new field in both tables of the same shape. (php mysql)

    I have two paintings: a table listing the projects and

    a table listing assignments for example, a project may have more than one assignment.

    When the user submits the form the insert record server behavior creates a new project. The projectID in the project table field is an AutoNumber created in mysql.

    Now when the new assignment record is created in the assignment table must use the projectID AutoNumber to refer to the parent project.

    That's the problem, I don't know how to get the new AutoNumber the table project. I tried setting a variable from a select query to find the last record on the project table... but the problem is that it assigns the value when you load the web page. If two users loading the same page before insertion, the action takes place so both are assigned the same projectID. Of course, which is useless.

    I'm not a programmer so need help to understand this.

    See you soon,.

    How to retrieve the value of an autoincrement column:

    http://www.gotocode.com/art.asp?art_id=80&

  • When I include photos from a folder in the Photos app in the dock, and I have created an album for them, their changes. It is important for me to keep them in the same order that they were in the file. (It's a numerical order). Any solution?

    Recently, I switched from PC to Mac, and I transferred all my files photo. Now I am their integration in the Photos app in the dock (by dragging the file etc). But when I include photos from a folder in the Photos app in the dock, and then create an album for them, their order in the album change of what it is in the file. It is important for me to keep them in the same order that they were in the file. (In the file it is in numerical order). Any solution?

    You can drag and drop to any order in your albums.

Maybe you are looking for