1 19 package bak.pcj.set; 20 21 import bak.pcj.AbstractIntCollection; 22 import bak.pcj.IntIterator; 23 import bak.pcj.hash.DefaultIntHashFunction; 24 25 37 public abstract class AbstractIntSet extends AbstractIntCollection implements IntSet { 38 39 40 protected AbstractIntSet() { } 41 42 public boolean equals(Object obj) { 43 if (!(obj instanceof IntSet)) 44 return false; 45 IntSet s = (IntSet)obj; 46 if (s.size() != size()) 47 return false; 48 return containsAll(s); 49 } 50 51 public int hashCode() { 52 int h = 0; 53 IntIterator i = iterator(); 54 while (i.hasNext()) 55 h += DefaultIntHashFunction.INSTANCE.hash(i.next()); 56 return h; 57 } 58 59 } | Popular Tags |