File:
Collection.d Originally written by Doug Lea and released into the public domain. Thanks for the assistance and support of Sun Microsystems Labs, Agorics Inc, Loral, and everyone contributing, testing, and using this code.History:
Date Who What 24Sep95 dl@cs.oswego.edu Create from tango.util.collection.d working file 13Oct95 dl Add assert 22Oct95 dl Add excludeElements, removeElements 28jan97 dl make class public; isolate version changes 14Dec06 kb Adapted for Tango usageAuthors:
Doug LeaSee Also:
tango.util.collection.impl.Collection.Collection.drainedReturns:
the count of elements currently in the collectionSee Also:
tango.util.collection.impl.Collection.Collection.sizeSee Also:
tango.util.collection.impl.Collection.Collection.allowsSee Also:
tango.util.collection.impl.Collection.Collection.matchesSee Also:
tango.util.collection.impl.Collection.Collection.versionSee Also:
tango.util.collection.model.View.View.checkImplementationParams:
| element | the element to exclude.
|
Params:
| element | the element to remove
|
1 2 3 4 5 6 7 8 | let int delta = oldElement.equals(newElement)? 0 : max(1, PREV(this).instances(oldElement) in instances(oldElement) == PREV(this).instances(oldElement) - delta && instances(newElement) == (this instanceof Set) ? max(1, PREV(this).instances(oldElement) + delta): PREV(this).instances(oldElement) + delta) && no other element changes && Version change iff delta != 0 |
Throws:
IllegalElementException if has(oldElement) and !allows(newElement)
1 2 3 4 5 6 7 8 | let int delta = oldElement.equals(newElement)? 0 : PREV(this).instances(oldElement) in instances(oldElement) == PREV(this).instances(oldElement) - delta && instances(newElement) == (this instanceof Set) ? max(1, PREV(this).instances(oldElement) + delta): PREV(this).instances(oldElement) + delta) && no other element changes && Version change iff delta != 0 |
Throws:
IllegalElementException if has(oldElement) and !allows(newElement)
1 2 | while (e.more()) removeAll(e.get()); |
Throws:
CorruptedIteratorException is propagated if thrownSee Also:
tango.util.collection.impl.Collection.Collection.removeAll
1 2 | while (e.more()) remove (e.get()); |
Param:
e = the enumeration of elements to remove.Throws:
CorruptedIteratorException is propagated if thrownExamples:
One way to transfer all elements from MutableCollection a to MutableBag b is:
1 2 | while (!a.empty()) b.add(a.take()); |
Returns:
an element v such that PREV(this).has(v) and the postconditions of removeOneOf(v) hold.Throws:
NoSuchElementException iff drained.