All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.roguewave.tools.v2-0.CollectionBase

java.lang.Object
   |
   +----com.roguewave.tools.v2-0.CollectionBase

public abstract class CollectionBase
extends Object
implements Collection, Serializable
Class CollectionBase is an abstract base class implementing the Collection interface. It is extended by most collection classes in the com.roguewave.tools.v2-0 package.

Classes that extend class Collection should use the protected member variable nitems_ to maintain the count of elements within the collection. Of course, all of the abstract methods must be overriden in the derived class. The methods size() and isEmpty() are marked final and cannot be overridden. Implementations are also provided for the apply() and reduce() methods.


Variable Index

 o nitems_
The number of items currently in the collection

Constructor Index

 o CollectionBase()

Method Index

 o apply(UnaryFunction)
Applies the UnaryFunction to every element of the collection in turn.
 o clear()
Removes all elements from the collection
 o contains(Object)
Returns true if an element equivalent to item is contained in the collection.
 o elements()
Returns an Enumeration object, which can be used to visit Each element of the collection in turn.
 o find(Object)
 o insert(Object)
Inserts item into the collection.
 o insertMany(Enumeration)
Inserts the elements in the Enumeration into the collection.
 o isEmpty()
Returns true if the collection is empty
 o occurrencesOf(Object)
Returns the number of elements in the collection equivalent to item.
 o reduce(BinaryFunction, Object)
Reduces the collection to a single value.
 o remove(Object)
Removes from the collection the first element that is equivalent to item.
 o removeAll(Object)
Removes from the collection all elements that are equivalent to item.
 o removeMany(Enumeration)
Removes from the collection the first element equivalent to each item in the Enumeration.
 o size()
Returns the number of entries in the collection

Variables

 o nitems_
 protected int nitems_
The number of items currently in the collection

Constructors

 o CollectionBase
 public CollectionBase()

Methods

 o apply
 public synchronized void apply(UnaryFunction f)
Applies the UnaryFunction to every element of the collection in turn. Note that the return value of the unary function is ignored.

 o clear
 public abstract void clear()
Removes all elements from the collection

 o contains
 public abstract boolean contains(Object item)
Returns true if an element equivalent to item is contained in the collection.

 o find
 public abstract Object find(Object item)
 o insert
 public abstract Object insert(Object item)
Inserts item into the collection.

Returns:
Collections that admit duplicate entries will usually return the new element just inserted. Collections that do not will usually return the new element if the insertion was successful, or the existing element whose presence caused the insertion to fail.
 o insertMany
 public synchronized int insertMany(Enumeration e)
Inserts the elements in the Enumeration into the collection.

Returns:
The number of elements inserted into the collection.
 o isEmpty
 public final boolean isEmpty()
Returns true if the collection is empty

 o size
 public final int size()
Returns the number of entries in the collection

 o elements
 public abstract Enumeration elements()
Returns an Enumeration object, which can be used to visit Each element of the collection in turn.

 o occurrencesOf
 public abstract int occurrencesOf(Object item)
Returns the number of elements in the collection equivalent to item.

 o reduce
 public synchronized Object reduce(BinaryFunction f,
                                   Object identity)
Reduces the collection to a single value. A result is initialized with identity. Then, for each element in the collection, a new result is computed by calling the BinaryFunction on the current result and the next element.

Returns:
The result as described above, or identity if the collection is empty.
 o remove
 public abstract Object remove(Object item)
Removes from the collection the first element that is equivalent to item.

 o removeMany
 public synchronized int removeMany(Enumeration e)
Removes from the collection the first element equivalent to each item in the Enumeration.

Returns:
The number of items removed.
 o removeAll
 public abstract int removeAll(Object item)
Removes from the collection all elements that are equivalent to item.


All Packages  Class Hierarchy  This Package  Previous  Next  Index