activemq-cpp-3.4.0

decaf::util::AbstractCollection< E > Class Template Reference

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

#include <src/main/decaf/util/AbstractCollection.h>

Inheritance diagram for decaf::util::AbstractCollection< E >:

Public Member Functions

 AbstractCollection ()
virtual ~AbstractCollection ()
AbstractCollection< E > & operator= (const AbstractCollection< E > &collection)
 Assignment Operator, copy element from the source collection to this collection after clearing any element stored in this collection.
virtual void clear ()
 Removes all of the elements from this collection (optional operation).
virtual bool contains (const E &value) const
 Returns true if this collection contains the specified element.More formally, returns true if and only if this collection contains at least one element e such that (value == NULL ? e == NULL : value == e ).
Parameters:
valueThe value to check for presence in the collection.
Returns:
true if there is at least one of the elements in the collection
Exceptions:
NullPointerExceptionif the Collection contains pointers and the Collection does not allow for NULL elements (optional check).

virtual bool containsAll (const Collection< E > &collection) const
 Returns true if this collection contains all of the elements in the specified collection.
Parameters:
collectionThe Collection to compare to this one.
Exceptions:
NullPointerExceptionif the Collection contains pointers and the Collection does not allow for NULL elements (optional check).

virtual bool equals (const Collection< E > &collection) const
 Answers true if this Collection and the one given are the same size and if each element contained in the Collection given is equal to an element contained in this collection.
virtual void copy (const Collection< E > &collection)
 Renders this Collection as a Copy of the given Collection.
virtual bool isEmpty () const
 Returns true if this collection contains no elements.
virtual bool add (const E &value DECAF_UNUSED)
 
virtual bool addAll (const Collection< E > &collection)
 Adds all of the elements in the specified collection to this collection.The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.)
Parameters:
collectionThe Collection whose elements are added to this one.
Returns:
true if this collection changed as a result of the call
Exceptions:
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.
IllegalArgumentExceptionif some property of an element prevents it from being added to this collection
IllegalStateExceptionif an element cannot be added at this time due to insertion restrictions.

virtual bool remove (const E &value)
 Removes a single instance of the specified element from the collection.More formally, removes an element e such that (value == NULL ? e == NULL : value == e), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).
Parameters:
valueThe reference to the element to remove from this Collection.
Returns:
true if the collection was changed, false otherwise.
Exceptions:
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.

virtual bool removeAll (const Collection< E > &collection)
 Removes all this collection's elements that are also contained in the specified collection (optional operation).After this call returns, this collection will contain no elements in common with the specified collection.
Parameters:
collectionThe Collection whose elements are to be removed from this one.
Returns:
true if the collection changed as a result of this call.
Exceptions:
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.

virtual bool retainAll (const Collection< E > &collection)
 Retains only the elements in this collection that are contained in the specified collection (optional operation).In other words, removes from this collection all of its elements that are not contained in the specified collection.
Parameters:
collectionThe Collection whose elements are to be retained.
Returns:
true if the collection changed as a result of this call.
Exceptions:
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.

virtual std::vector< E > toArray () const
 Answers an STL vector containing copies of all elements contained in this Collection.
virtual void lock ()
 Locks the object.
virtual bool tryLock ()
 Attempts to Lock the object, if the lock is already held by another thread than this method returns false.
virtual void unlock ()
 Unlocks the object.
virtual void wait ()
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void wait (long long millisecs)
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void wait (long long millisecs, int nanos)
 Waits on a signal from this object, which is generated by a call to Notify.
virtual void notify ()
 Signals a waiter on this object that it can now wake up and continue.
virtual void notifyAll ()
 Signals the waiters on this object that it can now wake up and continue.

Protected Attributes

util::concurrent::Mutex mutex

Detailed Description

template<typename E>
class decaf::util::AbstractCollection< E >

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 iterator and size methods. (The iterator returned by the iterator method must implement hasNext and next.)

To implement a modifiable collection, the programmer must additionally override this class's add method (which otherwise throws an UnsupportedOperationException), and the iterator returned by the iterator method must additionally implement its remove method.

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

The documentation for each non-abstract method in this class describes its implementation in detail. Each of these methods may be overridden if the collection being implemented admits a more efficient implementation.

Since:
1.0

Constructor & Destructor Documentation

template<typename E>
decaf::util::AbstractCollection< E >::AbstractCollection ( ) [inline]
template<typename E>
virtual decaf::util::AbstractCollection< E >::~AbstractCollection ( ) [inline, virtual]

Member Function Documentation

template<typename E>
virtual bool decaf::util::AbstractCollection< E >::add ( const E &value  DECAF_UNUSED) [inline, virtual]
template<typename E>
virtual bool decaf::util::AbstractCollection< E >::addAll ( const Collection< E > &  collection) [inline, virtual]

Adds all of the elements in the specified collection to this collection.The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (This implies that the behavior of this call is undefined if the specified collection is this collection, and this collection is nonempty.)

Parameters:
collectionThe Collection whose elements are added to this one.
Returns:
true if this collection changed as a result of the call
Exceptions:
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.
IllegalArgumentExceptionif some property of an element prevents it from being added to this collection
IllegalStateExceptionif an element cannot be added at this time due to insertion restrictions.

This implementation iterates over the specified collection, and adds each object returned by the iterator to this collection, in turn.

Note that this implementation will throw an UnsupportedOperationException unless add is overridden (assuming the specified collection is non-empty).

Implements decaf::util::Collection< E >.

Reimplemented in decaf::util::AbstractQueue< E >, decaf::util::ArrayList< E >, decaf::util::concurrent::CopyOnWriteArraySet< E >, decaf::util::LinkedList< E >, decaf::util::StlList< E >, decaf::util::LinkedList< Pointer< Transport > >, decaf::util::LinkedList< cms::MessageConsumer * >, decaf::util::LinkedList< CompositeTask * >, decaf::util::LinkedList< URI >, decaf::util::LinkedList< Pointer< MessageDispatch > >, decaf::util::LinkedList< Pointer< DestinationInfo > >, decaf::util::LinkedList< PrimitiveValueNode >, decaf::util::LinkedList< Pointer< Command > >, decaf::util::LinkedList< Pointer< BackupTransport > >, decaf::util::LinkedList< cms::MessageProducer * >, decaf::util::LinkedList< cms::Destination * >, decaf::util::LinkedList< cms::Session * >, and decaf::util::LinkedList< cms::Connection * >.

template<typename E>
virtual void decaf::util::AbstractCollection< E >::clear ( ) [inline, virtual]

Removes all of the elements from this collection (optional operation).

The collection will be empty after this method returns.

This implementation iterates over this collection, removing each element using the Iterator.remove operation. Most implementations will probably choose to override this method for efficiency.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection is non-empty.

Exceptions:
UnsupportedOperationExceptionif the clear operation is not supported by this collection

Implements decaf::util::Collection< E >.

Reimplemented in decaf::util::AbstractList< E >, decaf::util::AbstractQueue< E >, decaf::util::ArrayList< E >, decaf::util::concurrent::CopyOnWriteArraySet< E >, decaf::util::concurrent::LinkedBlockingQueue< E >, decaf::util::concurrent::SynchronousQueue< E >, decaf::util::LinkedList< E >, decaf::util::PriorityQueue< E >, decaf::util::StlList< E >, decaf::util::StlSet< E >, decaf::util::AbstractList< Pointer< Transport > >, decaf::util::AbstractList< cms::MessageConsumer * >, decaf::util::AbstractList< CompositeTask * >, decaf::util::AbstractList< URI >, decaf::util::AbstractList< Pointer< MessageDispatch > >, decaf::util::AbstractList< Pointer< DestinationInfo > >, decaf::util::AbstractList< PrimitiveValueNode >, decaf::util::AbstractList< Pointer< Command > >, decaf::util::AbstractList< Pointer< BackupTransport > >, decaf::util::AbstractList< cms::MessageProducer * >, decaf::util::AbstractList< cms::Destination * >, decaf::util::AbstractList< cms::Session * >, decaf::util::AbstractList< cms::Connection * >, decaf::util::LinkedList< Pointer< Transport > >, decaf::util::LinkedList< cms::MessageConsumer * >, decaf::util::LinkedList< CompositeTask * >, decaf::util::LinkedList< URI >, decaf::util::LinkedList< Pointer< MessageDispatch > >, decaf::util::LinkedList< Pointer< DestinationInfo > >, decaf::util::LinkedList< PrimitiveValueNode >, decaf::util::LinkedList< Pointer< Command > >, decaf::util::LinkedList< Pointer< BackupTransport > >, decaf::util::LinkedList< cms::MessageProducer * >, decaf::util::LinkedList< cms::Destination * >, decaf::util::LinkedList< cms::Session * >, decaf::util::LinkedList< cms::Connection * >, decaf::util::StlSet< Pointer< Synchronization > >, and decaf::util::StlSet< Resource * >.

Referenced by decaf::util::AbstractCollection< cms::Connection * >::copy(), and decaf::util::AbstractCollection< cms::Connection * >::operator=().

template<typename E>
virtual bool decaf::util::AbstractCollection< E >::contains ( const E &  value) const [inline, virtual]

Returns true if this collection contains the specified element.More formally, returns true if and only if this collection contains at least one element e such that (value == NULL ? e == NULL : value == e ).

Parameters:
valueThe value to check for presence in the collection.
Returns:
true if there is at least one of the elements in the collection
Exceptions:
NullPointerExceptionif the Collection contains pointers and the Collection does not allow for NULL elements (optional check).

This implementation iterates over the elements in the collection, checking each element in turn for equality with the specified element.

Implements decaf::util::Collection< E >.

Reimplemented in decaf::util::ArrayList< E >, decaf::util::concurrent::CopyOnWriteArraySet< E >, decaf::util::LinkedList< E >, decaf::util::StlList< E >, decaf::util::StlSet< E >, decaf::util::LinkedList< Pointer< Transport > >, decaf::util::LinkedList< cms::MessageConsumer * >, decaf::util::LinkedList< CompositeTask * >, decaf::util::LinkedList< URI >, decaf::util::LinkedList< Pointer< MessageDispatch > >, decaf::util::LinkedList< Pointer< DestinationInfo > >, decaf::util::LinkedList< PrimitiveValueNode >, decaf::util::LinkedList< Pointer< Command > >, decaf::util::LinkedList< Pointer< BackupTransport > >, decaf::util::LinkedList< cms::MessageProducer * >, decaf::util::LinkedList< cms::Destination * >, decaf::util::LinkedList< cms::Session * >, decaf::util::LinkedList< cms::Connection * >, decaf::util::StlSet< Pointer< Synchronization > >, and decaf::util::StlSet< Resource * >.

Referenced by decaf::util::AbstractCollection< cms::Connection * >::containsAll().

template<typename E>
virtual bool decaf::util::AbstractCollection< E >::containsAll ( const Collection< E > &  collection) const [inline, virtual]

Returns true if this collection contains all of the elements in the specified collection.

Parameters:
collectionThe Collection to compare to this one.
Exceptions:
NullPointerExceptionif the Collection contains pointers and the Collection does not allow for NULL elements (optional check).

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 decaf::util::Collection< E >.

Reimplemented in decaf::util::concurrent::CopyOnWriteArraySet< E >, and decaf::util::concurrent::SynchronousQueue< E >.

Referenced by decaf::util::AbstractCollection< cms::Connection * >::equals().

template<typename E>
virtual bool decaf::util::AbstractCollection< E >::equals ( const Collection< E > &  collection) const [inline, virtual]

Answers true if this Collection and the one given are the same size and if each element contained in the Collection given is equal to an element contained in this collection.

Parameters:
collection- The Collection to be compared to this one.
Returns:
true if this Collection is equal to the one given.

Implements decaf::util::Collection< E >.

Reimplemented in decaf::util::concurrent::CopyOnWriteArraySet< E >, decaf::util::concurrent::SynchronousQueue< E >, decaf::util::StlList< E >, decaf::util::StlSet< E >, decaf::util::StlSet< Pointer< Synchronization > >, and decaf::util::StlSet< Resource * >.

template<typename E>
virtual void decaf::util::AbstractCollection< E >::lock ( ) [inline, virtual]
template<typename E>
virtual void decaf::util::AbstractCollection< E >::notify ( ) [inline, virtual]

Signals a waiter on this object that it can now wake up and continue.

Must have this object locked before calling.

Exceptions:
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.
RuntimeExceptionif an error occurs while notifying one of the waiting threads.

Implements decaf::util::concurrent::Synchronizable.

template<typename E>
virtual void decaf::util::AbstractCollection< E >::notifyAll ( ) [inline, virtual]

Signals the waiters on this object that it can now wake up and continue.

Must have this object locked before calling.

Exceptions:
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.
RuntimeExceptionif an error occurs while notifying the waiting threads.

Implements decaf::util::concurrent::Synchronizable.

template<typename E>
AbstractCollection<E>& decaf::util::AbstractCollection< E >::operator= ( const AbstractCollection< E > &  collection) [inline]

Assignment Operator, copy element from the source collection to this collection after clearing any element stored in this collection.

Parameters:
collection- the collection to copy
Returns:
a reference to this collection
template<typename E>
virtual bool decaf::util::AbstractCollection< E >::remove ( const E &  value) [inline, virtual]

Removes a single instance of the specified element from the collection.More formally, removes an element e such that (value == NULL ? e == NULL : value == e), if this collection contains one or more such elements. Returns true if this collection contained the specified element (or equivalently, if this collection changed as a result of the call).

Parameters:
valueThe reference to the element to remove from this Collection.
Returns:
true if the collection was changed, false otherwise.
Exceptions:
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.

This implementation iterates over the collection looking for the specified element. If it finds the element, it removes the element from the collection using the iterator's remove method.

Note that this implementation throws an UnsupportedOperationException if the iterator returned by this collection's iterator method does not implement the remove method and this collection contains the specified object.

Implements decaf::util::Collection< E >.

Reimplemented in decaf::util::ArrayList< E >, decaf::util::concurrent::CopyOnWriteArraySet< E >, decaf::util::concurrent::LinkedBlockingQueue< E >, decaf::util::LinkedList< E >, decaf::util::PriorityQueue< E >, decaf::util::StlList< E >, decaf::util::StlSet< E >, decaf::util::LinkedList< Pointer< Transport > >, decaf::util::LinkedList< cms::MessageConsumer * >, decaf::util::LinkedList< CompositeTask * >, decaf::util::LinkedList< URI >, decaf::util::LinkedList< Pointer< MessageDispatch > >, decaf::util::LinkedList< Pointer< DestinationInfo > >, decaf::util::LinkedList< PrimitiveValueNode >, decaf::util::LinkedList< Pointer< Command > >, decaf::util::LinkedList< Pointer< BackupTransport > >, decaf::util::LinkedList< cms::MessageProducer * >, decaf::util::LinkedList< cms::Destination * >, decaf::util::LinkedList< cms::Session * >, decaf::util::LinkedList< cms::Connection * >, decaf::util::StlSet< Pointer< Synchronization > >, and decaf::util::StlSet< Resource * >.

template<typename E>
virtual bool decaf::util::AbstractCollection< E >::removeAll ( const Collection< E > &  collection) [inline, virtual]

Removes all this collection's elements that are also contained in the specified collection (optional operation).After this call returns, this collection will contain no elements in common with the specified collection.

Parameters:
collectionThe Collection whose elements are to be removed from this one.
Returns:
true if the collection changed as a result of this call.
Exceptions:
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements in common with the specified collection.

Implements decaf::util::Collection< E >.

Reimplemented in decaf::util::AbstractSet< E >, decaf::util::concurrent::CopyOnWriteArraySet< E >, decaf::util::AbstractSet< Pointer< Synchronization > >, and decaf::util::AbstractSet< Resource * >.

template<typename E>
virtual bool decaf::util::AbstractCollection< E >::retainAll ( const Collection< E > &  collection) [inline, virtual]

Retains only the elements in this collection that are contained in the specified collection (optional operation).In other words, removes from this collection all of its elements that are not contained in the specified collection.

Parameters:
collectionThe Collection whose elements are to be retained.
Returns:
true if the collection changed as a result of this call.
Exceptions:
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.

This implementation iterates over this collection, checking each element returned by the iterator in turn to see if it's contained in the specified collection. If it's not so contained, it's removed from this collection with the iterator's remove method.

Note that this implementation will throw an UnsupportedOperationException if the iterator returned by the iterator method does not implement the remove method and this collection contains one or more elements not present in the specified collection.

Implements decaf::util::Collection< E >.

Reimplemented in decaf::util::concurrent::CopyOnWriteArraySet< E >.

template<typename E>
virtual bool decaf::util::AbstractCollection< E >::tryLock ( ) [inline, virtual]

Attempts to Lock the object, if the lock is already held by another thread than this method returns false.

Returns:
true if the lock was acquired, false if it is already held by another thread.
Exceptions:
RuntimeExceptionif an error occurs while locking the object.

Implements decaf::util::concurrent::Synchronizable.

template<typename E>
virtual void decaf::util::AbstractCollection< E >::unlock ( ) [inline, virtual]

Unlocks the object.

Exceptions:
RuntimeExceptionif an error occurs while unlocking the object.

Implements decaf::util::concurrent::Synchronizable.

template<typename E>
virtual void decaf::util::AbstractCollection< E >::wait ( long long  millisecs,
int  nanos 
) [inline, virtual]

Waits on a signal from this object, which is generated by a call to Notify.

Must have this object locked before calling. This wait will timeout after the specified time interval. This method is similar to the one argument wait function except that it add a finer grained control over the amount of time that it waits by adding in the additional nanosecond argument.

NOTE: The ability to wait accurately at a nanosecond scale depends on the platform and OS that the Decaf API is running on, some systems do not provide an accurate enough clock to provide this level of granularity.

Parameters:
millisecsthe time in milliseconds to wait, or WAIT_INIFINITE
nanosadditional time in nanoseconds with a range of 0-999999
Exceptions:
IllegalArgumentExceptionif an error occurs or the nanos argument is not in the range of [0-999999]
RuntimeExceptionif an error occurs while waiting on the object.
InterruptedExceptionif the wait is interrupted before it completes.
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.

Implements decaf::util::concurrent::Synchronizable.

template<typename E>
virtual void decaf::util::AbstractCollection< E >::wait ( ) [inline, virtual]

Waits on a signal from this object, which is generated by a call to Notify.

Must have this object locked before calling.

Exceptions:
RuntimeExceptionif an error occurs while waiting on the object.
InterruptedExceptionif the wait is interrupted before it completes.
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.

Implements decaf::util::concurrent::Synchronizable.

template<typename E>
virtual void decaf::util::AbstractCollection< E >::wait ( long long  millisecs) [inline, virtual]

Waits on a signal from this object, which is generated by a call to Notify.

Must have this object locked before calling. This wait will timeout after the specified time interval.

Parameters:
millisecsthe time in milliseconds to wait, or WAIT_INIFINITE
Exceptions:
RuntimeExceptionif an error occurs while waiting on the object.
InterruptedExceptionif the wait is interrupted before it completes.
IllegalMonitorStateException- if the current thread is not the owner of the the Synchronizable Object.

Implements decaf::util::concurrent::Synchronizable.


Field Documentation


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