All Packages Class Hierarchy This Package Previous Next Index
Class collections.UpdatableImpl
java.lang.Object
|
+----collections.UpdatableImpl
- public abstract class UpdatableImpl
- extends Object
- implements UpdatableCollection
UpdatableImpl serves as a convenient base class for most
implementations of updatable collections. It maintains
a version number and element count.
It also provides default implementations of many
collection operations.
-
count_
- count_ holds the number of elements.
-
screener_
-
screener_ hold the supplied element screener
-
version_
-
version_ represents the current version number
-
UpdatableImpl()
- Initialize at version 0, an empty count, and null screener
-
UpdatableImpl(Predicate)
- Initialize at version 0, an empty count, and supplied screener
-
addToCount(int)
- add to the element count and update version_ if changed
-
assert(boolean)
- Implements collections.ImplementationCheckable.assert.
-
canInclude(Object)
- Implements collections.Collection.canInclude.
-
checkElement(Object)
- Principal method to throw a IllegalElementException
-
checkImplementation()
- Implements collections.ImplementationCheckable.checkImplementation.
-
checkIndex(int)
- Principal method to throw a NoSuchElementException.
-
clear()
- Cause the collection to become empty.
-
decCount()
- Decrement the element count and update version_
-
duplicate()
- Wrapper for clone()
-
elements()
- Return an enumeration that may be used to traverse through
the elements in the collection.
-
exclude(Object)
- Exclude all occurrences of the indicated element from the collection.
-
excludeElements(Enumeration)
-
Implements collections.UpdatableCollection.excludeElements
-
excluding(Object)
- Implements collections.Collection.excluding.
-
incCount()
- Increment the element count and update version_
-
includes(Object)
- Report whether the collection contains element.
-
incVersion()
- change the version number
-
isEmpty()
- Implements collections.Collection.isEmpty.
-
occurrencesOf(Object)
- Report the number of occurrences of element in collection.
-
removeElements(Enumeration)
-
Implements collections.UpdatableCollection.removeElements
-
removeOneOf(Object)
- Remove an instance of the indicated element from the collection.
-
removingOneOf(Object)
- Implements collections.Collection.removingOneOf
-
replaceAllOf(Object, Object)
- Replace all occurrences of oldElement with newElement.
-
replaceOneOf(Object, Object)
- Replace an occurrence of oldElement with newElement.
-
replacingAllOf(Object, Object)
- Implements collections.Collection.replacingAllOf
-
replacingOneOf(Object, Object)
- Implements collections.Collection.replacingOneOf
-
sameInclusions(Collection, Collection)
-
-
sameOccurrences(Collection, Collection)
-
-
sameOrderedElements(Collection, Collection)
-
-
sameOrderedPairs(Map, Map)
-
-
samePairs(Map, Map)
-
-
sameStructure(Collection)
- Implements collections.Collection.sameStructure
Time complexity: O(n).
-
setCount(int)
- set the element count and update version_ if changed
-
size()
- Implements collections.Collection.size.
-
take()
- Remove and return an element.
-
toString()
- Default implementation of toString for Collections.
-
version()
-
Implements collections.UpdatableCollection.version.
version_
protected int version_
- version_ represents the current version number
screener_
protected Predicate screener_
- screener_ hold the supplied element screener
count_
protected int count_
- count_ holds the number of elements.
UpdatableImpl
protected UpdatableImpl()
- Initialize at version 0, an empty count, and null screener
UpdatableImpl
protected UpdatableImpl(Predicate screener)
- Initialize at version 0, an empty count, and supplied screener
duplicate
public synchronized Collection duplicate()
- Wrapper for clone()
- See Also:
- clone
isEmpty
public synchronized boolean isEmpty()
- Implements collections.Collection.isEmpty.
Time complexity: O(1).
- See Also:
- isEmpty
size
public synchronized int size()
- Implements collections.Collection.size.
Time complexity: O(1).
- See Also:
- size
canInclude
public boolean canInclude(Object element)
- Implements collections.Collection.canInclude.
Time complexity: O(1) + time of screener, if present
- See Also:
- canInclude
sameStructure
public synchronized boolean sameStructure(Collection other)
- Implements collections.Collection.sameStructure
Time complexity: O(n).
Default implementation. Fairly sleazy approach.
(Defensible only when you remember that it is just a default impl.)
It tries to cast to one of the known collection interface types
and then applies the corresponding comparison rules.
This suffices for all currently supported collection types,
but must be overridden if you define new Collection subinterfaces
and/or implementations.
- See Also:
- sameStructure
removingOneOf
public synchronized Collection removingOneOf(Object element)
- Implements collections.Collection.removingOneOf
- See Also:
- removingOneOf
excluding
public synchronized Collection excluding(Object element)
- Implements collections.Collection.excluding.
- See Also:
- excluding
replacingOneOf
public synchronized Collection replacingOneOf(Object oldElement,
Object newElement) throws IllegalElementException
- Implements collections.Collection.replacingOneOf
- See Also:
- replacingOneOf
replacingAllOf
public synchronized Collection replacingAllOf(Object oldElement,
Object newElement) throws IllegalElementException
- Implements collections.Collection.replacingAllOf
- See Also:
- replacingAllOf
version
public synchronized int version()
- Implements collections.UpdatableCollection.version.
Time complexity: O(1).
- See Also:
- version
excludeElements
public synchronized void excludeElements(Enumeration e) throws CorruptedEnumerationException
- Implements collections.UpdatableCollection.excludeElements
- See Also:
- excludeElements
removeElements
public synchronized void removeElements(Enumeration e) throws CorruptedEnumerationException
- Implements collections.UpdatableCollection.removeElements
- See Also:
- removeElements
toString
public synchronized String toString()
- Default implementation of toString for Collections. Not
very pretty, but parenthesizing each element means that
for most kinds of elements, it's conceivable that the
strings could be parsed and used to build other collections.
Not a very pretty implementation either. Casts are used
to get at elements/keys
- Overrides:
- toString in class Object
incVersion
protected synchronized void incVersion()
- change the version number
incCount
protected final void incCount()
- Increment the element count and update version_
decCount
protected final void decCount()
- Decrement the element count and update version_
addToCount
protected final void addToCount(int c)
- add to the element count and update version_ if changed
setCount
protected final void setCount(int c)
- set the element count and update version_ if changed
sameInclusions
public static boolean sameInclusions(Collection s,
Collection t)
sameOccurrences
public static boolean sameOccurrences(Collection s,
Collection t)
sameOrderedElements
public static boolean sameOrderedElements(Collection s,
Collection t)
samePairs
public static boolean samePairs(Map s,
Map t)
sameOrderedPairs
public static boolean sameOrderedPairs(Map s,
Map t)
checkIndex
protected void checkIndex(int index) throws NoSuchElementException
- Principal method to throw a NoSuchElementException.
Besides index checks in Seqs, you can use it to check for
operations on empty collections via checkIndex(0)
checkElement
protected void checkElement(Object element) throws IllegalElementException
- Principal method to throw a IllegalElementException
assert
public void assert(boolean pred) throws ImplementationError
- Implements collections.ImplementationCheckable.assert.
- See Also:
- assert
checkImplementation
public synchronized void checkImplementation() throws ImplementationError
- Implements collections.ImplementationCheckable.checkImplementation.
- See Also:
- checkImplementation
All Packages Class Hierarchy This Package Previous Next Index