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.


Variable Index

 o count_
count_ holds the number of elements.
 o screener_
screener_ hold the supplied element screener
 o version_
version_ represents the current version number

Constructor Index

 o UpdatableImpl()
Initialize at version 0, an empty count, and null screener
 o UpdatableImpl(Predicate)
Initialize at version 0, an empty count, and supplied screener

Method Index

 o addToCount(int)
add to the element count and update version_ if changed
 o assert(boolean)
Implements collections.ImplementationCheckable.assert.
 o canInclude(Object)
Implements collections.Collection.canInclude.
 o checkElement(Object)
Principal method to throw a IllegalElementException
 o checkImplementation()
Implements collections.ImplementationCheckable.checkImplementation.
 o checkIndex(int)
Principal method to throw a NoSuchElementException.
 o clear()
Cause the collection to become empty.
 o decCount()
Decrement the element count and update version_
 o duplicate()
Wrapper for clone()
 o elements()
Return an enumeration that may be used to traverse through the elements in the collection.
 o exclude(Object)
Exclude all occurrences of the indicated element from the collection.
 o excludeElements(Enumeration)
Implements collections.UpdatableCollection.excludeElements
 o excluding(Object)
Implements collections.Collection.excluding.
 o incCount()
Increment the element count and update version_
 o includes(Object)
Report whether the collection contains element.
 o incVersion()
change the version number
 o isEmpty()
Implements collections.Collection.isEmpty.
 o occurrencesOf(Object)
Report the number of occurrences of element in collection.
 o removeElements(Enumeration)
Implements collections.UpdatableCollection.removeElements
 o removeOneOf(Object)
Remove an instance of the indicated element from the collection.
 o removingOneOf(Object)
Implements collections.Collection.removingOneOf
 o replaceAllOf(Object, Object)
Replace all occurrences of oldElement with newElement.
 o replaceOneOf(Object, Object)
Replace an occurrence of oldElement with newElement.
 o replacingAllOf(Object, Object)
Implements collections.Collection.replacingAllOf
 o replacingOneOf(Object, Object)
Implements collections.Collection.replacingOneOf
 o sameInclusions(Collection, Collection)
 o sameOccurrences(Collection, Collection)
 o sameOrderedElements(Collection, Collection)
 o sameOrderedPairs(Map, Map)
 o samePairs(Map, Map)
 o sameStructure(Collection)
Implements collections.Collection.sameStructure Time complexity: O(n).
 o setCount(int)
set the element count and update version_ if changed
 o size()
Implements collections.Collection.size.
 o take()
Remove and return an element.
 o toString()
Default implementation of toString for Collections.
 o version()
Implements collections.UpdatableCollection.version.

Variables

 o version_
 protected int version_
version_ represents the current version number

 o screener_
 protected Predicate screener_
screener_ hold the supplied element screener

 o count_
 protected int count_
count_ holds the number of elements.

Constructors

 o UpdatableImpl
 protected UpdatableImpl()
Initialize at version 0, an empty count, and null screener

 o UpdatableImpl
 protected UpdatableImpl(Predicate screener)
Initialize at version 0, an empty count, and supplied screener

Methods

 o duplicate
 public synchronized Collection duplicate()
Wrapper for clone()

See Also:
clone
 o isEmpty
 public synchronized boolean isEmpty()
Implements collections.Collection.isEmpty. Time complexity: O(1).

See Also:
isEmpty
 o size
 public synchronized int size()
Implements collections.Collection.size. Time complexity: O(1).

See Also:
size
 o canInclude
 public boolean canInclude(Object element)
Implements collections.Collection.canInclude. Time complexity: O(1) + time of screener, if present

See Also:
canInclude
 o 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
 o removingOneOf
 public synchronized Collection removingOneOf(Object element)
Implements collections.Collection.removingOneOf

See Also:
removingOneOf
 o excluding
 public synchronized Collection excluding(Object element)
Implements collections.Collection.excluding.

See Also:
excluding
 o replacingOneOf
 public synchronized Collection replacingOneOf(Object oldElement,
                                               Object newElement) throws IllegalElementException
Implements collections.Collection.replacingOneOf

See Also:
replacingOneOf
 o replacingAllOf
 public synchronized Collection replacingAllOf(Object oldElement,
                                               Object newElement) throws IllegalElementException
Implements collections.Collection.replacingAllOf

See Also:
replacingAllOf
 o version
 public synchronized int version()
Implements collections.UpdatableCollection.version. Time complexity: O(1).

See Also:
version
 o excludeElements
 public synchronized void excludeElements(Enumeration e) throws CorruptedEnumerationException
Implements collections.UpdatableCollection.excludeElements

See Also:
excludeElements
 o removeElements
 public synchronized void removeElements(Enumeration e) throws CorruptedEnumerationException
Implements collections.UpdatableCollection.removeElements

See Also:
removeElements
 o 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
 o incVersion
 protected synchronized void incVersion()
change the version number

 o incCount
 protected final void incCount()
Increment the element count and update version_

 o decCount
 protected final void decCount()
Decrement the element count and update version_

 o addToCount
 protected final void addToCount(int c)
add to the element count and update version_ if changed

 o setCount
 protected final void setCount(int c)
set the element count and update version_ if changed

 o sameInclusions
 public static boolean sameInclusions(Collection s,
                                      Collection t)
 o sameOccurrences
 public static boolean sameOccurrences(Collection s,
                                       Collection t)
 o sameOrderedElements
 public static boolean sameOrderedElements(Collection s,
                                           Collection t)
 o samePairs
 public static boolean samePairs(Map s,
                                 Map t)
 o sameOrderedPairs
 public static boolean sameOrderedPairs(Map s,
                                        Map t)
 o 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)

 o checkElement
 protected void checkElement(Object element) throws IllegalElementException
Principal method to throw a IllegalElementException

 o assert
 public void assert(boolean pred) throws ImplementationError
Implements collections.ImplementationCheckable.assert.

See Also:
assert
 o checkImplementation
 public synchronized void checkImplementation() throws ImplementationError
Implements collections.ImplementationCheckable.checkImplementation.

See Also:
checkImplementation

All Packages  Class Hierarchy  This Package  Previous  Next  Index