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