1 47 48 package org.ozoneDB.collections; 49 50 import java.util.Collection ; 51 import java.util.Iterator ; 52 import java.util.Set ; 53 54 68 public abstract class AbstractOzoneSet extends AbstractOzoneCollection implements OzoneSet { 69 70 private static final long serialVersionUID = 1L; 71 72 protected AbstractOzoneSet() { 73 } 74 75 85 public boolean equals(Object o) { 86 return super.equals(o) || (o instanceof Set && ((Set ) o).size() == size() && containsAll((Collection ) o)); 87 } 88 89 97 public int hashCode() { 98 Iterator itr = _org_ozoneDB_internalIterator(); 99 int hash = 0; 100 int pos = size(); 101 while (--pos >= 0) 102 hash += hashCode(itr.next()); 103 return hash; 104 } 105 106 123 public boolean removeAll(Collection c) { 124 int oldsize = size(); 125 int count = c.size(); 126 Iterator i; 127 if (oldsize < count) { 128 for (i = _org_ozoneDB_internalIterator(), count = oldsize; count > 0; count--) { 129 if (c.contains(i.next())) { 130 i.remove(); 131 } 132 } 133 } else { 134 Iterator itr; 135 if (c instanceof OzoneCollection) { 136 itr = ((OzoneCollection) c)._org_ozoneDB_internalIterator(); 137 } else { 138 itr = c.iterator(); 139 } 140 for (; count > 0; count--) { 141 remove(itr.next()); 142 } 143 } 144 return oldsize != size(); 145 } 146 147 159 public Set getClientSet() { 160 throw new UnsupportedOperationException (); 161 } 162 163 } | Popular Tags |