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 >:
Inheritance graph
[legend]

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:
value The value to check for presence in the collection.
Returns:
true if there is at least one of the elements in the collection
Exceptions:
NullPointerException if the Collection contains pointers and the Collection does not allow for NULL elements (optional check).

virtual bool containsAll (const Collection< E > &collection) const
 
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)
 
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:
value The reference to the element to remove from this Collection.
Returns:
true if the collection was changed, false otherwise.
Exceptions:
UnsupportedOperationExceptio if this is an unmodifiable collection.
NullPointerException if the Collection is a container of pointers and does not allow NULL values.

virtual bool removeAll (const Collection< E > &collection)
 
virtual bool retainAll (const Collection< E > &collection)
 
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]

This implementation always throws an UnsupportedOperationException.

Referenced by decaf::util::AbstractCollection< K >::addAll(), decaf::util::AbstractCollection< K >::copy(), and decaf::util::AbstractCollection< K >::operator=().

template<typename E>
virtual bool decaf::util::AbstractCollection< E >::addAll ( const Collection< E > &  collection  )  [inline, virtual]
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:
UnsupportedOperationException if 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::HashMap< K, V, HASHCODE >::HashMapEntrySet, decaf::util::HashMap< K, V, HASHCODE >::ConstHashMapEntrySet, decaf::util::HashMap< K, V, HASHCODE >::HashMapKeySet, decaf::util::HashMap< K, V, HASHCODE >::ConstHashMapKeySet, decaf::util::HashMap< K, V, HASHCODE >::HashMapValueCollection, decaf::util::HashMap< K, V, HASHCODE >::ConstHashMapValueCollection, decaf::util::LinkedList< E >, decaf::util::PriorityQueue< E >, decaf::util::StlList< E >, decaf::util::StlSet< E >, decaf::util::AbstractList< ServiceListener * >, 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< decaf::net::URI >, decaf::util::AbstractList< Pointer< Command > >, decaf::util::AbstractList< cms::MessageProducer * >, decaf::util::AbstractList< cms::Destination * >, decaf::util::AbstractList< cms::Session * >, decaf::util::AbstractList< Pointer< ActiveMQDestination > >, decaf::util::AbstractList< cms::Connection * >, decaf::util::AbstractQueue< Pointer< Transport > >, decaf::util::ArrayList< ServiceListener * >, decaf::util::ArrayList< Pointer< ActiveMQDestination > >, decaf::util::concurrent::LinkedBlockingQueue< 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< decaf::net::URI >, decaf::util::LinkedList< Pointer< Command > >, 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< K >::copy(), and decaf::util::AbstractCollection< K >::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:
value The value to check for presence in the collection.
Returns:
true if there is at least one of the elements in the collection
Exceptions:
NullPointerException if 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::HashMap< K, V, HASHCODE >::HashMapKeySet, decaf::util::HashMap< K, V, HASHCODE >::ConstHashMapKeySet, decaf::util::HashMap< K, V, HASHCODE >::HashMapValueCollection, decaf::util::HashMap< K, V, HASHCODE >::ConstHashMapValueCollection, decaf::util::LinkedList< E >, decaf::util::StlList< E >, decaf::util::StlSet< E >, decaf::util::ArrayList< ServiceListener * >, decaf::util::ArrayList< Pointer< ActiveMQDestination > >, 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< decaf::net::URI >, decaf::util::LinkedList< Pointer< Command > >, 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< K >::containsAll().

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

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.

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

Referenced by decaf::util::AbstractCollection< K >::equals().

template<typename E>
virtual void decaf::util::AbstractCollection< E >::copy ( const Collection< E > &  collection  )  [inline, virtual]
template<typename E>
virtual bool decaf::util::AbstractCollection< E >::equals ( const Collection< E > &  collection  )  const [inline, virtual]
template<typename E>
virtual bool decaf::util::AbstractCollection< E >::isEmpty (  )  const [inline, virtual]
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.
RuntimeException if 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.
RuntimeException if 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]
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:
value The reference to the element to remove from this Collection.
Returns:
true if the collection was changed, false otherwise.
Exceptions:
UnsupportedOperationExceptio if this is an unmodifiable collection.
NullPointerException if 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::HashMap< K, V, HASHCODE >::HashMapEntrySet, decaf::util::HashMap< K, V, HASHCODE >::HashMapKeySet, decaf::util::LinkedList< E >, decaf::util::PriorityQueue< E >, decaf::util::StlList< E >, decaf::util::StlSet< E >, decaf::util::ArrayList< ServiceListener * >, decaf::util::ArrayList< Pointer< ActiveMQDestination > >, 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< decaf::net::URI >, decaf::util::LinkedList< Pointer< Command > >, 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]

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.

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

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

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.

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

template<typename E>
virtual std::vector<E> decaf::util::AbstractCollection< E >::toArray (  )  const [inline, virtual]
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:
RuntimeException if 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:
RuntimeException if 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:
millisecs the time in milliseconds to wait, or WAIT_INIFINITE
nanos additional time in nanoseconds with a range of 0-999999
Exceptions:
IllegalArgumentException if an error occurs or the nanos argument is not in the range of [0-999999]
RuntimeException if an error occurs while waiting on the object.
InterruptedException if 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:
millisecs the time in milliseconds to wait, or WAIT_INIFINITE
Exceptions:
RuntimeException if an error occurs while waiting on the object.
InterruptedException if 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:
RuntimeException if an error occurs while waiting on the object.
InterruptedException if 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

template<typename E>
util::concurrent::Mutex decaf::util::AbstractCollection< E >::mutex [mutable, protected]

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

Generated on 1 Dec 2014 for activemq-cpp-3.8.2 by  doxygen 1.6.1