Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>EDIT: I've just thought of something which could <em>certainly</em> cause a problem. Do you ever <em>modify</em> the array in <code>Matrix</code>? You <em>mustn't</em> change the relevant values within a key after adding it to a map - it will potentially cause false positives and even false negatives (you could use the same key reference you used in <code>put</code> and not find a match with <code>get</code> if you've made a change which affects the hash code, for example).</p> <hr> <p>It's not clear what code is printing the "Recognized hashCode" part... but it sounds like it's <em>assuming</em> hash codes are unique. <strong>Don't do that.</strong> They're not <em>supposed</em> to be unique. They're meant to be an indication of <em>possible</em> equality - an optimization to make finding something faster. The idea is that if you find a matching hash code, you should <em>always</em> check for "real" equality.</p> <p>You haven't said what the values in your array are, but assuming they're 0 (empty) 1 (black) and 2 (white) there are <em>far</em> more possible combinations of those than a plain ol' 32-bit hash code can represent... you've got 3<sup>64</sup> possibilities, which is rather more than 2<sup>32</sup>. Now I dare say most of those aren't really feasible Othello boards, but I'd be surprised if <code>Arrays.deepHashCode</code> attempted to optimize for exactly this case, in order to provide unique hash codes for all valid Othello boards, even if that <em>is</em> possible.</p> <p>As a side note, your <code>hashCode</code> method is rather more complicated than it needs to be. Try this:</p> <pre><code>@Override public int hashCode() { return Arrays.deepHashCode(board); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload