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