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