Oracle Coherence for C++ API
Release 3.6.0.0
E15728-01

- Main Page
- Namespaces
- Classes
- Files

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Collection Class Reference

`#include <coherence/util/Collection.hpp>`

Inherits Object.

Inherited by AbstractCollection `[virtual]`, List `[virtual]`, NullImplementation::NullCollection `[virtual]`, Set `[virtual]`, and WrapperCollections::AbstractWrapperCollection `[virtual]`.

List of all members.

## Detailed Description

The base interface of all collections managed by Coherence.

A collection is a group of objects also known as elements. The following behaviors of a collection are implementation dependent:

- ordered iteration
- support for duplicate elements
- element equivalency by state equality (Object::equals())
- accessibility of elements only as views
- retention of elements by copy
- thread-safe

Unless otherwise stated, collections are assumed to not support any of the above.

See also:
  Iterator

  List

  Map

  Set

Author:
  jh/mf/nsa 2008.01.28

## Public Types
typedef spec::Handle | Handle
| Collection Handle definition.
typedef spec::View | View
| Collection View definition.
typedef spec::Holder | Holder
| Collection Holder definition.
## Public Member Functions
virtual size32_t | size () const =0
| Return the number of elements in this collection.
virtual bool | isEmpty () const =0
| Determine whether this collection contains any elements.
virtual bool | contains (Object::View v) const =0
| Determine if this collection contains the specified element.
virtual bool | containsAll (Collection::View vCol) const =0
| Determine if this collection contains all elements from the supplied collection.
virtual Iterator::Handle | iterator () const =0
| Return an Iterator over this collection.
virtual Muterator::Handle | iterator ()=0
| Return an Iterator over this collection.
virtual ObjectArray::Handle | toArray (ObjectArray::Handle hao=NULL) const =0
| Return the contents of this collection as an ObjectArray.
virtual bool | add (Object::Holder oh)=0
| Add the given element to this collection.
virtual bool | addAll (Collection::View vCol)=0
| Add all elements from the supplied collection to this collection.
virtual bool | remove (Object::View v)=0
| Remove the supplied element from this collection.
virtual bool | removeAll (Collection::View vCol)=0
| Remove all instances of the elements in the supplied collection from this collection.
virtual bool | retainAll (Collection::View vCol)=0
| Remove all elements from this collection that are not present in the supplied collection.
virtual void | clear ()=0
| Remove all elements from this collection.

## Member Function Documentation

virtual size32_t size | ( |  | ) | const `[pure virtual]`

Return the number of elements in this collection.

Returns:
  the number of elements in this collection

Implemented in AbstractCollection, CircularArrayList, DeltaSet, LinkedList, ReadOnlyMultiList, SafeHashMap::EntrySet, SubList, SubSet, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual bool isEmpty | ( |  | ) | const `[pure virtual]`

Determine whether this collection contains any elements.

Returns:
  true if this collection has no elements

Implemented in AbstractCollection, SubSet, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual bool contains | ( | Object::View | v | ) | const `[pure virtual]`

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

Implemented in AbstractCollection, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, DeltaSet, MapKeySet, MapValuesCollection, ReadOnlyMultiList, SafeHashMap::EntrySet, SubSet, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual bool containsAll | ( | Collection::View | vCol | ) | const `[pure 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()

Implemented in AbstractCollection, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, MapKeySet, MapValuesCollection, SubSet, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual Iterator::Handle iterator | ( |  | ) | const `[pure virtual]`

Return an Iterator over this collection.

Returns:
  an Iterator over this collection

Implemented in CircularArrayList, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, DeltaSet, LinkedList, MappedSet, ReadOnlyMultiList, SafeHashMap::EntrySet, SubList, SubSet, TypedCollections::TypedCollection, TypedCollections::TypedSet, TypedCollections::TypedList, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual Muterator::Handle iterator | ( |  | ) | `[pure virtual]`

Return an Iterator over this collection.

Returns:
  an Iterator over this collection

Implemented in CircularArrayList, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, DeltaSet, LinkedList, MappedSet, ReadOnlyMultiList, SafeHashMap::EntrySet, SubList, SubSet, TypedCollections::TypedCollection, TypedCollections::TypedSet, TypedCollections::TypedList, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual ObjectArray::Handle toArray | ( | ObjectArray::Handle | hao = `NULL` | ) | const `[pure virtual]`

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

Implemented in AbstractCollection, CircularArrayList, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, DeltaSet, ReadOnlyMultiList, SafeHashMap::EntrySet, SubSet, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual bool add | ( | Object::Holder | oh | ) | `[pure 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

Implemented in AbstractCollection, CircularArrayList, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, DeltaSet, LinkedList, MappedSet, SubList, SubSet, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual bool addAll | ( | Collection::View | vCol | ) | `[pure 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()

Implemented in AbstractCollection, CircularArrayList, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, LinkedList, MappedSet, SubList, SubSet, TypedCollections::TypedCollection, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual bool remove | ( | Object::View | v | ) | `[pure 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

Implemented in AbstractCollection, CircularArrayList, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, DeltaSet, LinkedList, MapKeySet, MapValuesCollection, SafeHashMap::EntrySet, SubList, SubSet, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual bool removeAll | ( | Collection::View | vCol | ) | `[pure 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()

Implemented in AbstractCollection, CircularArrayList, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, LinkedList, MapKeySet, MapValuesCollection, SubSet, TypedCollections::TypedCollection, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

virtual bool retainAll | ( | Collection::View | vCol | ) | `[pure 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()

Implemented in AbstractCollection, CircularArrayList, CircularArrayList::SubCircularArrayList, ConverterCollections::ConverterCollection, ConverterCollections::ConverterSet, LinkedList, LinkedList::SubLinkedList, MapKeySet, MapValuesCollection, SubSet, TypedCollections::TypedCollection, WrapperCollections::AbstractWrapperCollection, WrapperCollections::AbstractWrapperSet, and WrapperCollections::AbstractWrapperList.

The documentation for this class was generated from the following file:

- coherence/util/Collection.hpp

Copyright © 2000, 2010, Oracle and/or its affiliates. All rights reserved.