Source code: org/pokersource/enum/HandMatchup.java
1 // $Id: HandMatchup.java,v 1.4 2002/06/13 03:04:56 mjmaurer Exp $
2
3 package org.pokersource.enum;
4
5 /**
6 @author Michael Maurer <mjmaurer@yahoo.com>
7 */
8
9 public class HandMatchup {
10 public long matchHands[]; // matchHands[i] is player i's hand
11 private int hash;
12
13 public HandMatchup(long matchHands[]) {
14 this.matchHands = (long[]) matchHands.clone();
15 computeHash();
16 }
17
18 public boolean equals(Object o) {
19 HandMatchup other = (HandMatchup) o;
20 return java.util.Arrays.equals(this.matchHands, other.matchHands);
21 }
22
23 private void computeHash() {
24 // hash = matchHands.hashCode() --- WRONG: not equal for equal arrays
25 hash = matchHands.length;
26 for (int i=0; i<matchHands.length; i++)
27 hash = (hash << 1) ^ (new Long(matchHands[i])).hashCode();
28 }
29
30 public int hashCode() {
31 return hash;
32 }
33 }