Methods Summary |
---|
public boolean | equals(java.lang.Object object)Compares the specified object to this Set and returns true if they are
equal. The object must be an instance of Set and contain the same
objects.
if (this == object) {
return true;
}
if (object instanceof Set) {
Set<?> s = (Set<?>) object;
// BEGIN android-changed
// copied from a newer version of harmony
try {
return size() == s.size() && containsAll(s);
} catch (ClassCastException cce) {
return false;
}
// END android-changed
}
return false;
|
public int | hashCode()Returns the hash code for this set. Two set which are equal must return
the same value. This implementation calculates the hash code by adding
each element's hash code.
int result = 0;
Iterator<?> it = iterator();
while (it.hasNext()) {
Object next = it.next();
result += next == null ? 0 : next.hashCode();
}
return result;
|
public boolean | removeAll(java.util.Collection collection)Removes all occurrences in this collection which are contained in the
specified collection.
boolean result = false;
if (size() <= collection.size()) {
Iterator<?> it = iterator();
while (it.hasNext()) {
if (collection.contains(it.next())) {
it.remove();
result = true;
}
}
} else {
Iterator<?> it = collection.iterator();
while (it.hasNext()) {
result = remove(it.next()) || result;
}
}
return result;
|