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.
-
nitems_
- The number of items currently in the collection
-
CollectionBase()
-
-
apply(UnaryFunction)
- Applies the UnaryFunction to every element of the collection
in turn.
-
clear()
- Removes all elements from the collection
-
contains(Object)
- Returns true if an element equivalent to item is
contained in the collection.
-
elements()
- Returns an Enumeration object, which can be used to visit
Each element of the collection in turn.
-
find(Object)
-
-
insert(Object)
- Inserts item into the collection.
-
insertMany(Enumeration)
- Inserts the elements in the Enumeration into the collection.
-
isEmpty()
- Returns true if the collection is empty
-
occurrencesOf(Object)
- Returns the number of elements in the collection equivalent
to item.
-
reduce(BinaryFunction, Object)
- Reduces the collection to a single value.
-
remove(Object)
- Removes from the collection the first element
that is equivalent to item.
-
removeAll(Object)
- Removes from the collection all elements that are
equivalent to item.
-
removeMany(Enumeration)
- Removes from the collection the first element equivalent to
each item in the Enumeration.
-
size()
- Returns the number of entries in the collection
nitems_
protected int nitems_
- The number of items currently in the collection
CollectionBase
public CollectionBase()
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.
clear
public abstract void clear()
- Removes all elements from the collection
contains
public abstract boolean contains(Object item)
- Returns true if an element equivalent to item is
contained in the collection.
find
public abstract Object find(Object item)
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.
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.
isEmpty
public final boolean isEmpty()
- Returns true if the collection is empty
size
public final int size()
- Returns the number of entries in the collection
elements
public abstract Enumeration elements()
- Returns an Enumeration object, which can be used to visit
Each element of the collection in turn.
occurrencesOf
public abstract int occurrencesOf(Object item)
- Returns the number of elements in the collection equivalent
to item.
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.
remove
public abstract Object remove(Object item)
- Removes from the collection the first element
that is equivalent to item.
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.
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