Update of /cvsroot/trove4j/trove/src/gnu/trove In directory sc8-pr-cvs1:/tmp/cvs-serv19510/src/gnu/trove Modified Files: TDoubleDoubleHashMap.java TDoubleFloatHashMap.java TDoubleHash.java TDoubleHashSet.java TDoubleIntHashMap.java TDoubleLongHashMap.java TDoubleObjectHashMap.java TFloatDoubleHashMap.java TFloatFloatHashMap.java TFloatHash.java TFloatHashSet.java TFloatIntHashMap.java TFloatLongHashMap.java TFloatObjectHashMap.java THashMap.java THashMapTests.java THashSet.java TIntArrayListTests.java TIntDoubleHashMap.java TIntFloatHashMap.java TIntHash.java TIntHashSet.java TIntIntHashMap.java TIntLongHashMap.java TIntObjectHashMap.java TLongDoubleHashMap.java TLongFloatHashMap.java TLongHash.java TLongHashSet.java TLongIntHashMap.java TLongLongHashMap.java TLongObjectHashMap.java TObjectHash.java gen_primitive_base.pl gen_primitive_map.pl gen_primitive_set.pl Log Message: made maps, sets implement hashCode based on their contents Index: TDoubleDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleDoubleHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TDoubleDoubleHashMap.java 22 Sep 2002 21:53:39 -0000 1.13 --- TDoubleDoubleHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TDoubleDoubleProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(double key, double value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TDoubleDoubleProcedure { private final TDoubleDoubleHashMap _otherMap; Index: TDoubleFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleFloatHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TDoubleFloatHashMap.java 22 Sep 2002 21:53:39 -0000 1.13 --- TDoubleFloatHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TDoubleFloatProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(double key, float value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TDoubleFloatProcedure { private final TDoubleFloatHashMap _otherMap; Index: TDoubleHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleHash.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TDoubleHash.java 22 Sep 2002 21:53:40 -0000 1.12 --- TDoubleHash.java 19 Mar 2003 04:17:03 -0000 1.13 *************** *** 37,41 **** /** strategy used to hash values in this collection */ ! private TDoubleHashingStrategy hashingStrategy; /** --- 37,41 ---- /** strategy used to hash values in this collection */ ! protected TDoubleHashingStrategy _hashingStrategy; /** *************** *** 45,49 **** public TDoubleHash() { super(); ! this.hashingStrategy = this; } --- 45,49 ---- public TDoubleHash() { super(); ! this._hashingStrategy = this; } *************** *** 57,61 **** public TDoubleHash(int initialCapacity) { super(initialCapacity); ! this.hashingStrategy = this; } --- 57,61 ---- public TDoubleHash(int initialCapacity) { super(initialCapacity); ! this._hashingStrategy = this; } *************** *** 70,74 **** public TDoubleHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this.hashingStrategy = this; } --- 70,74 ---- public TDoubleHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this._hashingStrategy = this; } *************** *** 80,84 **** public TDoubleHash(TDoubleHashingStrategy strategy) { super(); ! this.hashingStrategy = strategy; } --- 80,84 ---- public TDoubleHash(TDoubleHashingStrategy strategy) { super(); ! this._hashingStrategy = strategy; } *************** *** 93,97 **** public TDoubleHash(int initialCapacity, TDoubleHashingStrategy strategy) { super(initialCapacity); ! this.hashingStrategy = strategy; } --- 93,97 ---- public TDoubleHash(int initialCapacity, TDoubleHashingStrategy strategy) { super(initialCapacity); ! this._hashingStrategy = strategy; } *************** *** 107,111 **** public TDoubleHash(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this.hashingStrategy = strategy; } --- 107,111 ---- public TDoubleHash(int initialCapacity, float loadFactor, TDoubleHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this._hashingStrategy = strategy; } *************** *** 186,190 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; --- 186,190 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; *************** *** 222,226 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; --- 222,226 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; Index: TDoubleHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleHashSet.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TDoubleHashSet.java 22 Sep 2002 21:53:40 -0000 1.10 --- TDoubleHashSet.java 19 Mar 2003 04:17:03 -0000 1.11 *************** *** 230,233 **** --- 230,252 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEach(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TDoubleProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(double key) { + h += _hashingStrategy.computeHashCode(key); + return true; + } + } + /** * Removes <tt>val</tt> from the set. Index: TDoubleIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleIntHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TDoubleIntHashMap.java 22 Sep 2002 21:53:40 -0000 1.13 --- TDoubleIntHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TDoubleIntProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(double key, int value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TDoubleIntProcedure { private final TDoubleIntHashMap _otherMap; Index: TDoubleLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleLongHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TDoubleLongHashMap.java 22 Sep 2002 21:53:40 -0000 1.13 --- TDoubleLongHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TDoubleLongProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(double key, long value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TDoubleLongProcedure { private final TDoubleLongHashMap _otherMap; Index: TDoubleObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TDoubleObjectHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TDoubleObjectHashMap.java 22 Sep 2002 21:53:40 -0000 1.13 --- TDoubleObjectHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TDoubleObjectProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(double key, Object value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TDoubleObjectProcedure { private final TDoubleObjectHashMap _otherMap; Index: TFloatDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatDoubleHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TFloatDoubleHashMap.java 22 Sep 2002 21:53:40 -0000 1.13 --- TFloatDoubleHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TFloatDoubleProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(float key, double value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TFloatDoubleProcedure { private final TFloatDoubleHashMap _otherMap; Index: TFloatFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatFloatHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TFloatFloatHashMap.java 22 Sep 2002 21:53:40 -0000 1.13 --- TFloatFloatHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TFloatFloatProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(float key, float value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TFloatFloatProcedure { private final TFloatFloatHashMap _otherMap; Index: TFloatHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatHash.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TFloatHash.java 22 Sep 2002 21:53:40 -0000 1.12 --- TFloatHash.java 19 Mar 2003 04:17:03 -0000 1.13 *************** *** 37,41 **** /** strategy used to hash values in this collection */ ! private TFloatHashingStrategy hashingStrategy; /** --- 37,41 ---- /** strategy used to hash values in this collection */ ! protected TFloatHashingStrategy _hashingStrategy; /** *************** *** 45,49 **** public TFloatHash() { super(); ! this.hashingStrategy = this; } --- 45,49 ---- public TFloatHash() { super(); ! this._hashingStrategy = this; } *************** *** 57,61 **** public TFloatHash(int initialCapacity) { super(initialCapacity); ! this.hashingStrategy = this; } --- 57,61 ---- public TFloatHash(int initialCapacity) { super(initialCapacity); ! this._hashingStrategy = this; } *************** *** 70,74 **** public TFloatHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this.hashingStrategy = this; } --- 70,74 ---- public TFloatHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this._hashingStrategy = this; } *************** *** 80,84 **** public TFloatHash(TFloatHashingStrategy strategy) { super(); ! this.hashingStrategy = strategy; } --- 80,84 ---- public TFloatHash(TFloatHashingStrategy strategy) { super(); ! this._hashingStrategy = strategy; } *************** *** 93,97 **** public TFloatHash(int initialCapacity, TFloatHashingStrategy strategy) { super(initialCapacity); ! this.hashingStrategy = strategy; } --- 93,97 ---- public TFloatHash(int initialCapacity, TFloatHashingStrategy strategy) { super(initialCapacity); ! this._hashingStrategy = strategy; } *************** *** 107,111 **** public TFloatHash(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this.hashingStrategy = strategy; } --- 107,111 ---- public TFloatHash(int initialCapacity, float loadFactor, TFloatHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this._hashingStrategy = strategy; } *************** *** 186,190 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; --- 186,190 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; *************** *** 222,226 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; --- 222,226 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; Index: TFloatHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatHashSet.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TFloatHashSet.java 22 Sep 2002 21:53:40 -0000 1.10 --- TFloatHashSet.java 19 Mar 2003 04:17:03 -0000 1.11 *************** *** 230,233 **** --- 230,252 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEach(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TFloatProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(float key) { + h += _hashingStrategy.computeHashCode(key); + return true; + } + } + /** * Removes <tt>val</tt> from the set. Index: TFloatIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatIntHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TFloatIntHashMap.java 22 Sep 2002 21:53:40 -0000 1.13 --- TFloatIntHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TFloatIntProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(float key, int value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TFloatIntProcedure { private final TFloatIntHashMap _otherMap; Index: TFloatLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatLongHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TFloatLongHashMap.java 22 Sep 2002 21:53:41 -0000 1.13 --- TFloatLongHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TFloatLongProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(float key, long value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TFloatLongProcedure { private final TFloatLongHashMap _otherMap; Index: TFloatObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TFloatObjectHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TFloatObjectHashMap.java 22 Sep 2002 21:53:41 -0000 1.13 --- TFloatObjectHashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TFloatObjectProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(float key, Object value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TFloatObjectProcedure { private final TFloatObjectHashMap _otherMap; Index: THashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/THashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** THashMap.java 20 Sep 2002 20:55:57 -0000 1.13 --- THashMap.java 19 Mar 2003 04:17:03 -0000 1.14 *************** *** 203,206 **** --- 203,225 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TObjectObjectProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(Object key, Object value) { + h += (_hashingStrategy.computeHashCode(key) ^ (value == null ? 0 : value.hashCode())); + return true; + } + } + private static final class EqProcedure implements TObjectObjectProcedure { private final Map _otherMap; Index: THashMapTests.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/THashMapTests.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** THashMapTests.java 20 Sep 2002 20:55:57 -0000 1.11 --- THashMapTests.java 19 Mar 2003 04:17:03 -0000 1.12 *************** *** 330,332 **** --- 330,344 ---- assertTrue(! map.equals(m2)); } + + public void testHashCode() throws Exception { + THashMap m1 = new THashMap(); + THashMap m2 = new THashMap(); + m1.put(new String("foo"), new String("bar")); + m2.put(new String("foo"), new String("bar")); + assertEquals(m1.hashCode(), m2.hashCode()); + assertEquals(m1, m2); + m2.put(new String("cruft"), new String("bar")); + assertTrue(m1.hashCode() != m2.hashCode()); + assertTrue(! m1.equals(m2)); + } } // THashMapTests Index: THashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/THashSet.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** THashSet.java 18 Aug 2002 16:43:14 -0000 1.9 --- THashSet.java 19 Mar 2003 04:17:04 -0000 1.10 *************** *** 160,163 **** --- 160,182 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEach(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TObjectProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(Object key) { + h += _hashingStrategy.computeHashCode(key); + return true; + } + } + /** * Expands the set to accomodate new values. Index: TIntArrayListTests.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntArrayListTests.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** TIntArrayListTests.java 8 Jul 2002 00:51:20 -0000 1.4 --- TIntArrayListTests.java 19 Mar 2003 04:17:04 -0000 1.5 *************** *** 52,55 **** --- 52,64 ---- } + public void testFill() { + assertEquals(0, list.size()); + list.fill(10); + assertEquals(0, list.size()); + list.fill(0, 100, 10); + assertEquals(100, list.size()); + assertEquals(10, list.get(5)); + } + public void testSize() { assertEquals(0, list.size()); Index: TIntDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntDoubleHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TIntDoubleHashMap.java 22 Sep 2002 21:53:41 -0000 1.13 --- TIntDoubleHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TIntDoubleProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(int key, double value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TIntDoubleProcedure { private final TIntDoubleHashMap _otherMap; Index: TIntFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntFloatHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TIntFloatHashMap.java 22 Sep 2002 21:53:41 -0000 1.13 --- TIntFloatHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TIntFloatProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(int key, float value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TIntFloatProcedure { private final TIntFloatHashMap _otherMap; Index: TIntHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntHash.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TIntHash.java 22 Sep 2002 21:53:41 -0000 1.12 --- TIntHash.java 19 Mar 2003 04:17:04 -0000 1.13 *************** *** 37,41 **** /** strategy used to hash values in this collection */ ! private TIntHashingStrategy hashingStrategy; /** --- 37,41 ---- /** strategy used to hash values in this collection */ ! protected TIntHashingStrategy _hashingStrategy; /** *************** *** 45,49 **** public TIntHash() { super(); ! this.hashingStrategy = this; } --- 45,49 ---- public TIntHash() { super(); ! this._hashingStrategy = this; } *************** *** 57,61 **** public TIntHash(int initialCapacity) { super(initialCapacity); ! this.hashingStrategy = this; } --- 57,61 ---- public TIntHash(int initialCapacity) { super(initialCapacity); ! this._hashingStrategy = this; } *************** *** 70,74 **** public TIntHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this.hashingStrategy = this; } --- 70,74 ---- public TIntHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this._hashingStrategy = this; } *************** *** 80,84 **** public TIntHash(TIntHashingStrategy strategy) { super(); ! this.hashingStrategy = strategy; } --- 80,84 ---- public TIntHash(TIntHashingStrategy strategy) { super(); ! this._hashingStrategy = strategy; } *************** *** 93,97 **** public TIntHash(int initialCapacity, TIntHashingStrategy strategy) { super(initialCapacity); ! this.hashingStrategy = strategy; } --- 93,97 ---- public TIntHash(int initialCapacity, TIntHashingStrategy strategy) { super(initialCapacity); ! this._hashingStrategy = strategy; } *************** *** 107,111 **** public TIntHash(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this.hashingStrategy = strategy; } --- 107,111 ---- public TIntHash(int initialCapacity, float loadFactor, TIntHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this._hashingStrategy = strategy; } *************** *** 186,190 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; --- 186,190 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; *************** *** 222,226 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; --- 222,226 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; Index: TIntHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntHashSet.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TIntHashSet.java 22 Sep 2002 21:53:41 -0000 1.10 --- TIntHashSet.java 19 Mar 2003 04:17:04 -0000 1.11 *************** *** 230,233 **** --- 230,252 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEach(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TIntProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(int key) { + h += _hashingStrategy.computeHashCode(key); + return true; + } + } + /** * Removes <tt>val</tt> from the set. Index: TIntIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntIntHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TIntIntHashMap.java 22 Sep 2002 21:53:41 -0000 1.13 --- TIntIntHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TIntIntProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(int key, int value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TIntIntProcedure { private final TIntIntHashMap _otherMap; Index: TIntLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntLongHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TIntLongHashMap.java 22 Sep 2002 21:53:42 -0000 1.13 --- TIntLongHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TIntLongProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(int key, long value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TIntLongProcedure { private final TIntLongHashMap _otherMap; Index: TIntObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TIntObjectHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TIntObjectHashMap.java 22 Sep 2002 21:53:42 -0000 1.13 --- TIntObjectHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TIntObjectProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(int key, Object value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TIntObjectProcedure { private final TIntObjectHashMap _otherMap; Index: TLongDoubleHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongDoubleHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TLongDoubleHashMap.java 22 Sep 2002 21:53:42 -0000 1.13 --- TLongDoubleHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TLongDoubleProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(long key, double value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TLongDoubleProcedure { private final TLongDoubleHashMap _otherMap; Index: TLongFloatHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongFloatHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TLongFloatHashMap.java 22 Sep 2002 21:53:42 -0000 1.13 --- TLongFloatHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TLongFloatProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(long key, float value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TLongFloatProcedure { private final TLongFloatHashMap _otherMap; Index: TLongHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongHash.java,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** TLongHash.java 22 Sep 2002 21:53:42 -0000 1.12 --- TLongHash.java 19 Mar 2003 04:17:04 -0000 1.13 *************** *** 37,41 **** /** strategy used to hash values in this collection */ ! private TLongHashingStrategy hashingStrategy; /** --- 37,41 ---- /** strategy used to hash values in this collection */ ! protected TLongHashingStrategy _hashingStrategy; /** *************** *** 45,49 **** public TLongHash() { super(); ! this.hashingStrategy = this; } --- 45,49 ---- public TLongHash() { super(); ! this._hashingStrategy = this; } *************** *** 57,61 **** public TLongHash(int initialCapacity) { super(initialCapacity); ! this.hashingStrategy = this; } --- 57,61 ---- public TLongHash(int initialCapacity) { super(initialCapacity); ! this._hashingStrategy = this; } *************** *** 70,74 **** public TLongHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this.hashingStrategy = this; } --- 70,74 ---- public TLongHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this._hashingStrategy = this; } *************** *** 80,84 **** public TLongHash(TLongHashingStrategy strategy) { super(); ! this.hashingStrategy = strategy; } --- 80,84 ---- public TLongHash(TLongHashingStrategy strategy) { super(); ! this._hashingStrategy = strategy; } *************** *** 93,97 **** public TLongHash(int initialCapacity, TLongHashingStrategy strategy) { super(initialCapacity); ! this.hashingStrategy = strategy; } --- 93,97 ---- public TLongHash(int initialCapacity, TLongHashingStrategy strategy) { super(initialCapacity); ! this._hashingStrategy = strategy; } *************** *** 107,111 **** public TLongHash(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this.hashingStrategy = strategy; } --- 107,111 ---- public TLongHash(int initialCapacity, float loadFactor, TLongHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this._hashingStrategy = strategy; } *************** *** 186,190 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; --- 186,190 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; *************** *** 222,226 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; --- 222,226 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(val) & 0x7fffffff; index = hash % length; Index: TLongHashSet.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongHashSet.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** TLongHashSet.java 22 Sep 2002 21:53:42 -0000 1.10 --- TLongHashSet.java 19 Mar 2003 04:17:04 -0000 1.11 *************** *** 230,233 **** --- 230,252 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEach(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TLongProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(long key) { + h += _hashingStrategy.computeHashCode(key); + return true; + } + } + /** * Removes <tt>val</tt> from the set. Index: TLongIntHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongIntHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TLongIntHashMap.java 22 Sep 2002 21:53:42 -0000 1.13 --- TLongIntHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TLongIntProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(long key, int value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TLongIntProcedure { private final TLongIntHashMap _otherMap; Index: TLongLongHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongLongHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TLongLongHashMap.java 22 Sep 2002 21:53:42 -0000 1.13 --- TLongLongHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TLongLongProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(long key, long value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TLongLongProcedure { private final TLongLongHashMap _otherMap; Index: TLongObjectHashMap.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TLongObjectHashMap.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TLongObjectHashMap.java 22 Sep 2002 21:53:42 -0000 1.13 --- TLongObjectHashMap.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 250,253 **** --- 250,272 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements TLongObjectProcedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(long key, Object value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements TLongObjectProcedure { private final TLongObjectHashMap _otherMap; Index: TObjectHash.java =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/TObjectHash.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** TObjectHash.java 20 Sep 2002 20:55:58 -0000 1.13 --- TObjectHash.java 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 38,42 **** /** the strategy used to hash objects in this collection. */ ! private TObjectHashingStrategy hashingStrategy; protected static final Object REMOVED = new Object(); --- 38,42 ---- /** the strategy used to hash objects in this collection. */ ! protected TObjectHashingStrategy _hashingStrategy; protected static final Object REMOVED = new Object(); *************** *** 48,52 **** public TObjectHash() { super(); ! this.hashingStrategy = this; } --- 48,52 ---- public TObjectHash() { super(); ! this._hashingStrategy = this; } *************** *** 59,63 **** public TObjectHash(TObjectHashingStrategy strategy) { super(); ! this.hashingStrategy = strategy; } --- 59,63 ---- public TObjectHash(TObjectHashingStrategy strategy) { super(); ! this._hashingStrategy = strategy; } *************** *** 71,75 **** public TObjectHash(int initialCapacity) { super(initialCapacity); ! this.hashingStrategy = this; } --- 71,75 ---- public TObjectHash(int initialCapacity) { super(initialCapacity); ! this._hashingStrategy = this; } *************** *** 85,89 **** public TObjectHash(int initialCapacity, TObjectHashingStrategy strategy) { super(initialCapacity); ! this.hashingStrategy = strategy; } --- 85,89 ---- public TObjectHash(int initialCapacity, TObjectHashingStrategy strategy) { super(initialCapacity); ! this._hashingStrategy = strategy; } *************** *** 98,102 **** public TObjectHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this.hashingStrategy = this; } --- 98,102 ---- public TObjectHash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this._hashingStrategy = this; } *************** *** 113,117 **** public TObjectHash(int initialCapacity, float loadFactor, TObjectHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this.hashingStrategy = strategy; } --- 113,117 ---- public TObjectHash(int initialCapacity, float loadFactor, TObjectHashingStrategy strategy) { super(initialCapacity, loadFactor); ! this._hashingStrategy = strategy; } *************** *** 190,199 **** set = _set; length = set.length; ! hash = hashingStrategy.computeHashCode(obj) & 0x7fffffff; index = hash % length; cur = set[index]; if (cur != null ! && (cur == REMOVED || ! hashingStrategy.equals(cur, obj))) { // see Knuth, p. 529 probe = 1 + (hash % (length - 2)); --- 190,199 ---- set = _set; length = set.length; ! hash = _hashingStrategy.computeHashCode(obj) & 0x7fffffff; index = hash % length; cur = set[index]; if (cur != null ! && (cur == REMOVED || ! _hashingStrategy.equals(cur, obj))) { // see Knuth, p. 529 probe = 1 + (hash % (length - 2)); *************** *** 206,210 **** cur = set[index]; } while (cur != null ! && (cur == REMOVED || ! hashingStrategy.equals(cur, obj))); } --- 206,210 ---- cur = set[index]; } while (cur != null ! && (cur == REMOVED || ! _hashingStrategy.equals(cur, obj))); } *************** *** 229,233 **** set = _set; length = set.length; ! hash = hashingStrategy.computeHashCode(obj) & 0x7fffffff; index = hash % length; cur = set[index]; --- 229,233 ---- set = _set; length = set.length; ! hash = _hashingStrategy.computeHashCode(obj) & 0x7fffffff; index = hash % length; cur = set[index]; *************** *** 235,239 **** if (cur == null) { return index; // empty, all done ! } else if (hashingStrategy.equals(cur, obj)) { return -index -1; // already stored } else { // already FULL or REMOVED, must probe --- 235,239 ---- if (cur == null) { return index; // empty, all done ! } else if (_hashingStrategy.equals(cur, obj)) { return -index -1; // already stored } else { // already FULL or REMOVED, must probe *************** *** 250,254 **** } while (cur != null && cur != REMOVED ! && ! hashingStrategy.equals(cur, obj)); // if the index we found was removed: continue probing until we --- 250,254 ---- } while (cur != null && cur != REMOVED ! && ! _hashingStrategy.equals(cur, obj)); // if the index we found was removed: continue probing until we *************** *** 258,262 **** int firstRemoved = index; while (cur != null ! && (cur == REMOVED || ! hashingStrategy.equals(cur, obj))) { index -= probe; if (index < 0) { --- 258,262 ---- int firstRemoved = index; while (cur != null ! && (cur == REMOVED || ! _hashingStrategy.equals(cur, obj))) { index -= probe; if (index < 0) { Index: gen_primitive_base.pl =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/gen_primitive_base.pl,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** gen_primitive_base.pl 20 Sep 2002 20:55:58 -0000 1.10 --- gen_primitive_base.pl 19 Mar 2003 04:17:04 -0000 1.11 *************** *** 59,63 **** /** strategy used to hash values in this collection */ ! private T<Type>HashingStrategy hashingStrategy; /** --- 59,63 ---- /** strategy used to hash values in this collection */ ! protected T<Type>HashingStrategy _hashingStrategy; /** *************** *** 67,71 **** public T<Type>Hash() { super(); ! this.hashingStrategy = this; } --- 67,71 ---- public T<Type>Hash() { super(); ! this._hashingStrategy = this; } *************** *** 79,83 **** public T<Type>Hash(int initialCapacity) { super(initialCapacity); ! this.hashingStrategy = this; } --- 79,83 ---- public T<Type>Hash(int initialCapacity) { super(initialCapacity); ! this._hashingStrategy = this; } *************** *** 92,96 **** public T<Type>Hash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this.hashingStrategy = this; } --- 92,96 ---- public T<Type>Hash(int initialCapacity, float loadFactor) { super(initialCapacity, loadFactor); ! this._hashingStrategy = this; } *************** *** 102,106 **** public T<Type>Hash(T<Type>HashingStrategy strategy) { super(); ! this.hashingStrategy = strategy; } --- 102,106 ---- public T<Type>Hash(T<Type>HashingStrategy strategy) { super(); ! this._hashingStrategy = strategy; } *************** *** 115,119 **** public T<Type>Hash(int initialCapacity, T<Type>HashingStrategy strategy) { super(initialCapacity); ! this.hashingStrategy = strategy; } --- 115,119 ---- public T<Type>Hash(int initialCapacity, T<Type>HashingStrategy strategy) { super(initialCapacity); ! this._hashingStrategy = strategy; } *************** *** 129,133 **** public T<Type>Hash(int initialCapacity, float loadFactor, T<Type>HashingStrategy strategy) { super(initialCapacity, loadFactor); ! this.hashingStrategy = strategy; } --- 129,133 ---- public T<Type>Hash(int initialCapacity, float loadFactor, T<Type>HashingStrategy strategy) { super(initialCapacity, loadFactor); ! this._hashingStrategy = strategy; } *************** *** 208,212 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(<instance>) & 0x7fffffff; index = hash % length; --- 208,212 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(<instance>) & 0x7fffffff; index = hash % length; *************** *** 244,248 **** set = _set; length = states.length; ! hash = hashingStrategy.computeHashCode(<instance>) & 0x7fffffff; index = hash % length; --- 244,248 ---- set = _set; length = states.length; ! hash = _hashingStrategy.computeHashCode(<instance>) & 0x7fffffff; index = hash % length; Index: gen_primitive_map.pl =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/gen_primitive_map.pl,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** gen_primitive_map.pl 22 Sep 2002 21:53:42 -0000 1.13 --- gen_primitive_map.pl 19 Mar 2003 04:17:04 -0000 1.14 *************** *** 398,401 **** --- 398,420 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEachEntry(p); + return p.getHashCode(); + } + + private final class HashProcedure implements T<KeyType><ValueType>Procedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(<keyType> key, <valueType> value) { + h += (_hashingStrategy.computeHashCode(key) ^ HashFunctions.hash(value)); + return true; + } + } + private static final class EqProcedure implements T<KeyType><ValueType>Procedure { private final T<KeyType><ValueType>HashMap _otherMap; Index: gen_primitive_set.pl =================================================================== RCS file: /cvsroot/trove4j/trove/src/gnu/trove/gen_primitive_set.pl,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** gen_primitive_set.pl 22 Sep 2002 21:53:42 -0000 1.10 --- gen_primitive_set.pl 19 Mar 2003 04:17:04 -0000 1.11 *************** *** 251,254 **** --- 251,273 ---- } + public int hashCode() { + HashProcedure p = new HashProcedure(); + forEach(p); + return p.getHashCode(); + } + + private final class HashProcedure implements T<Type>Procedure { + private int h = 0; + + public int getHashCode() { + return h; + } + + public final boolean execute(<type> key) { + h += _hashingStrategy.computeHashCode(key); + return true; + } + } + /** * Removes <tt><instance></tt> from the set. |