Oracle Coherence for C++ API
Release 3.7.1.0

E22845-01

AbstractCollection Class Reference

#include <coherence/util/AbstractCollection.hpp>

Inherits Object, and Collection.

Inherited by AbstractList, AbstractSet, and SafeHashMap::EntrySet.

List of all members.


Detailed Description

This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface.

To implement an unmodifiable collection, the programmer needs only to extend this class and provide implementations for the size and iterator methods.

To implement a modifiable collection, the programmer must additionally override this class's add, remove, removeAll, retainAll and clear methods (which otherwise throw an UnsupportedOperationException).

The programmer should generally provide a void (no argument) and Collection constructor, as per the recommendation in the Collection interface specification.

See also:
Collection
 

Public Types

typedef spec::Handle Handle
 AbstractCollection Handle definition.
typedef spec::View View
 AbstractCollection View definition.
typedef spec::Holder Holder
 AbstractCollection Holder definition.

Public Member Functions

virtual size32_t size () const =0
 Return the number of elements in this collection.

Returns:
the number of elements in this collection
virtual bool isEmpty () const
 Determine whether this collection contains any elements.

Returns:
true if this collection has no elements
virtual bool contains (Object::View v) const
 Determine if this collection contains the specified element.

Parameters:
 v the element to test for containment
Returns:
true iff this collection contains the given element
virtual
ObjectArray::Handle 
toArray (ObjectArray::Handle hao=NULL) const
 Return the contents of this collection as an ObjectArray.

If the collection fits in the specified array, it is returned, otherwise, a new array is allocated that is the size of this collection.

If this collection fits in the array with aditional room then the element in the array immediately following the end of the collection is set to NULL. This can be useful in determining the length of this collection if the caller knows that the collection does not contain any NULL elements.

Parameters:
 hao an array in which to store the collection's contents
Returns:
a ObjectArray containing all the elements of the collection in the same order as returned by the collection's Iterator
See also:
Iterator
virtual bool containsAll (Collection::View vc) const
 Determine if this collection contains all elements from the supplied collection.

Parameters:
 vCol the collection of elements to test for containment
Returns:
true iff this collection contains all elements from the supplied collection
Exceptions:
 coherence::lang::NullPointerException if the specified collection is NULL
See also:
contains()
virtual bool add (Object::Holder oh)
 Add the given element to this collection.

Parameters:
 oh the element to add
Returns:
true iff this collection was modified as a result of this operation
virtual bool addAll (Collection::View vc)
 Add all elements from the supplied collection to this collection.

Parameters:
 vCol the collection of elements to add
Returns:
true iff this collection was modified as a result of this operation
Exceptions:
 coherence::lang::NullPointerException if the specified collection is NULL
See also:
add()
virtual bool remove (Object::View v)
 Remove the supplied element from this collection.

Parameters:
 v the element to remove
Returns:
true iff this collection was modified as a result of this operation
virtual bool removeAll (Collection::View vc)
 Remove all instances of the elements in the supplied collection from this collection.

Upon completion, contains() on this collection will return false for all elements in the supplied collection.

Parameters:
 vCol the collection of elements to remove
Returns:
true iff this collection was modified as a result of this operation
Exceptions:
 coherence::lang::NullPointerException if the specified collection is NULL
See also:
remove()

contains()

virtual bool retainAll (Collection::View vc)
 Remove all elements from this collection that are not present in the supplied collection.

Parameters:
 vCol the collection of elements to retain
Returns:
true iff this collection was modified as a result of this operation.
Exceptions:
 coherence::lang::NullPointerException if the specified collection is NULL
See also:
remove()

contains()

virtual void clear ()
 Remove all elements from this collection.
virtual void toStream (std::ostream &out) const
 Output a human-readable description of this Object to the given stream.

coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toStream method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents.

 Object::View vKey   = ...
 Object::View vValue = ...
 std::cout << vKey << " = " << vValue << std::endl;

 String::Handle hs = COH_TO_STRING(vKey << " = " << vValue);

Parameters:
 out the stream used to output the description

Member Function Documentation

virtual bool containsAll ( Collection::View  vc  )  const [virtual]

Determine if this collection contains all elements from the supplied collection.

Parameters:
 vCol the collection of elements to test for containment
Returns:
true iff this collection contains all elements from the supplied collection
Exceptions:
 coherence::lang::NullPointerException if the specified collection is NULL
See also:
contains()

This implementation iterates over the specified collection, checking each element returned by the iterator in turn to see if it's contained in this collection. If all elements are so contained true is returned, otherwise false.

Implements Collection.

Reimplemented in LiteSet, and SubSet.

virtual bool add ( Object::Holder  oh  )  [virtual]

Add the given element to this collection.

Parameters:
 oh the element to add
Returns:
true iff this collection was modified as a result of this operation

This implementation will throw a coherence::lang::UnsupportedOperationException

Implements Collection.

Reimplemented in CircularArrayList, DeltaSet, LinkedList, LiteSet, SubList, and SubSet.

virtual bool addAll ( Collection::View  vc  )  [virtual]

Add all elements from the supplied collection to this collection.

Parameters:
 vCol the collection of elements to add
Returns:
true iff this collection was modified as a result of this operation
Exceptions:
 coherence::lang::NullPointerException if the specified collection is NULL
See also:
add()

This implementation will throw a coherence::lang::UnsupportedOperationException unless add() is overridden (assuming the specified collection is non-empty).

Implements Collection.

Reimplemented in CircularArrayList, LinkedList, LiteSet, SubList, and SubSet.

virtual bool remove ( Object::View  v  )  [virtual]

Remove the supplied element from this collection.

Parameters:
 v the element to remove
Returns:
true iff this collection was modified as a result of this operation

This implementation will throw a coherence::lang::UnsupportedOperationException unless add() is overridden (assuming the specified collection is non-empty).

Implements Collection.

Reimplemented in CircularArrayList, DeltaSet, LinkedList, LiteSet, SafeHashMap::EntrySet, SubList, and SubSet.

virtual bool removeAll ( Collection::View  vc  )  [virtual]

Remove all instances of the elements in the supplied collection from this collection.

Upon completion, contains() on this collection will return false for all elements in the supplied collection.

Parameters:
 vCol the collection of elements to remove
Returns:
true iff this collection was modified as a result of this operation
Exceptions:
 coherence::lang::NullPointerException if the specified collection is NULL
See also:
remove()

contains()

This implementation will throw a coherence::lang::UnsupportedOperationException} unless remove() is overridden (assuming the specified collection is non-empty).

Implements Collection.

Reimplemented in CircularArrayList, LinkedList, LiteSet, and SubSet.

virtual bool retainAll ( Collection::View  vc  )  [virtual]

Remove all elements from this collection that are not present in the supplied collection.

Parameters:
 vCol the collection of elements to retain
Returns:
true iff this collection was modified as a result of this operation.
Exceptions:
 coherence::lang::NullPointerException if the specified collection is NULL
See also:
remove()

contains()

This implementation will throw a coherence::lang::UnsupportedOperationException unless remove() is overridden (assuming there are items to be removed by the operation).

Implements Collection.

Reimplemented in CircularArrayList, CircularArrayList::SubCircularArrayList, LinkedList, LinkedList::SubLinkedList, LiteSet, and SubSet.

virtual void clear (  )  [virtual]

Remove all elements from this collection.

This implementation will throw a coherence::lang::UnsupportedOperationException.

Implements Collection.

Reimplemented in CircularArrayList, CircularArrayList::SubCircularArrayList, DeltaSet, LinkedList, LinkedList::SubLinkedList, LiteSet, SafeHashMap::EntrySet, and SubSet.


The documentation for this class was generated from the following file:
Copyright © 2000, 2011, Oracle and/or its affiliates. All rights reserved.