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