activemq-cpp-3.6.0
decaf::util::AbstractList< E > Class Template Reference

This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array). More...

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

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

Data Structures

class  ConstSimpleListIterator
class  SimpleListIterator

Public Member Functions

 AbstractList ()
virtual ~AbstractList ()
virtual Iterator< E > * iterator ()
virtual Iterator< E > * iterator () const
virtual ListIterator< E > * listIterator ()
virtual ListIterator< E > * listIterator () const
virtual ListIterator< E > * listIterator (int index)
virtual ListIterator< E > * listIterator (int index) const
virtual void clear ()
 Removes all of the elements from this collection (optional operation).
virtual bool add (const E &value)
 Returns true if this collection changed as a result of the call.
virtual void add (int index DECAF_UNUSED, const E &element DECAF_UNUSED)
virtual bool addAll (int index, const Collection< E > &source)
 Inserts all of the elements in the specified collection into this list at the specified position (optional operation).
virtual E removeAt (int index DECAF_UNUSED)
 Removes the element at the specified position in this list.
virtual E set (int index DECAF_UNUSED, const E &element DECAF_UNUSED)
virtual int indexOf (const E &value) const
 Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.
virtual int lastIndexOf (const E &value) const
 Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.
- Public Member Functions inherited from decaf::util::List< E >
 List ()
virtual ~List ()
virtual E get (int index) const =0
 Gets the element contained at position passed.
virtual E set (int index, const E &element)=0
 Replaces the element at the specified position in this list with the specified element.
virtual void add (int index, const E &element)=0
 Inserts the specified element at the specified position in this list.
- Public Member Functions inherited from decaf::util::Collection< E >
virtual ~Collection ()
virtual int size () const =0
 Returns the number of elements in this collection.
- Public Member Functions inherited from decaf::lang::Iterable< E >
virtual ~Iterable ()
- Public Member Functions inherited from decaf::util::concurrent::Synchronizable
virtual ~Synchronizable ()
- Public Member Functions inherited from decaf::util::AbstractCollection< E >
 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 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 Member Functions

void removeRange (int start, int end)

Protected Attributes

int modCount
- Protected Attributes inherited from decaf::util::AbstractCollection< E >
util::concurrent::Mutex mutex

Detailed Description

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

This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a "random access" data store (such as an array).

For sequential access data (such as a linked list), AbstractSequentialList should be used in preference to this class.

To implement an unmodifiable list, the programmer needs only to extend this class and provide implementations for the get(int) and size() methods.

To implement a modifiable list, the programmer must additionally override the set(int, E) method (which otherwise throws an UnsupportedOperationException). If the list is variable-size the programmer must additionally override the add(int, E) and remove(int) methods.

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

Unlike the other abstract collection implementations, the programmer does not have to provide an iterator implementation; the iterator and list iterator are implemented by this class, on top of the "random access" methods: get(int), set(int, E), add(int, E) and remove(int).

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::AbstractList< E >::AbstractList ( )
inline
template<typename E>
virtual decaf::util::AbstractList< E >::~AbstractList ( )
inlinevirtual

Member Function Documentation

template<typename E>
virtual bool decaf::util::AbstractList< E >::add ( const E &  value)
inlinevirtual

Returns true if this collection changed as a result of the call.

(Returns false if this collection does not permit duplicates and already contains the specified element.)

Collections that support this operation may place limitations on what elements may be added to this collection. In particular, some collections will refuse to add null elements, and others will impose restrictions on the type of elements that may be added. Collection classes should clearly specify in their documentation any restrictions on what elements may be added.

If a collection refuses to add a particular element for any reason other than that it already contains the element, it must throw an exception (rather than returning false). This preserves the invariant that a collection always contains the specified element after this call returns.

For non-pointer values, i.e. class instances or string's the object will be copied into the collection, thus the object must support being copied, must not hide the copy constructor and assignment operator.

Parameters
valueThe reference to the element to add to this Collection.
Returns
true if the element was added to this Collection.
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 the element prevents it from being added to this collection
IllegalStateExceptionif the element cannot be added at this time due to insertion restrictions.

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

Reimplemented in decaf::util::StlList< E >, decaf::util::ArrayList< E >, decaf::util::ArrayList< ServiceListener * >, decaf::util::ArrayList< Pointer< ActiveMQDestination > >, decaf::util::LinkedList< E >, 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 * >, and decaf::util::LinkedList< cms::Connection * >.

Referenced by decaf::util::AbstractList< cms::Connection * >::add(), and decaf::util::AbstractList< cms::Connection * >::addAll().

template<typename E>
virtual void decaf::util::AbstractList< E >::add ( int index  DECAF_UNUSED,
const E &element  DECAF_UNUSED 
)
inlinevirtual
template<typename E>
virtual bool decaf::util::AbstractList< E >::addAll ( int  index,
const Collection< E > &  source 
)
inlinevirtual

Inserts all of the elements in the specified collection into this list at the specified position (optional operation).

Shifts the element currently at that position (if any) and any subsequent elements to the right (increases their indices). The new elements will appear in this list in the order that they are returned by the specified collection's iterator. The behavior of this operation is undefined if the specified collection is modified while the operation is in progress. (Note that this will occur if the specified collection is this list, and it's nonempty.)

Parameters
indexThe index at which to insert the first element from the specified collection
sourceThe Collection containing elements to be added to this list
Returns
true if this list changed as a result of the call
Exceptions
IndexOutOfBoundsExceptionif the index given is less than zero or greater than the List size.
UnsupportedOperationExceptioif this is an unmodifiable collection.
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.
IllegalArgumentExceptionif some property of the element prevents it from being added to this collection
IllegalStateExceptionif the element cannot be added at this time due to insertion restrictions.

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

Reimplemented in decaf::util::StlList< E >, decaf::util::ArrayList< E >, decaf::util::ArrayList< ServiceListener * >, decaf::util::ArrayList< Pointer< ActiveMQDestination > >, decaf::util::LinkedList< E >, 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::AbstractSequentialList< E >, decaf::util::AbstractSequentialList< cms::MessageConsumer * >, decaf::util::AbstractSequentialList< CompositeTask * >, decaf::util::AbstractSequentialList< URI >, decaf::util::AbstractSequentialList< Pointer< MessageDispatch > >, decaf::util::AbstractSequentialList< Pointer< DestinationInfo > >, decaf::util::AbstractSequentialList< PrimitiveValueNode >, decaf::util::AbstractSequentialList< decaf::net::URI >, decaf::util::AbstractSequentialList< Pointer< Command > >, decaf::util::AbstractSequentialList< cms::MessageProducer * >, decaf::util::AbstractSequentialList< cms::Destination * >, decaf::util::AbstractSequentialList< cms::Session * >, and decaf::util::AbstractSequentialList< cms::Connection * >.

template<typename E>
virtual void decaf::util::AbstractList< E >::clear ( )
inlinevirtual

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

Reimplemented from decaf::util::AbstractCollection< E >.

Reimplemented in decaf::util::StlList< E >, decaf::util::LinkedList< E >, 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::ArrayList< E >, decaf::util::ArrayList< ServiceListener * >, and decaf::util::ArrayList< Pointer< ActiveMQDestination > >.

template<typename E>
virtual int decaf::util::AbstractList< E >::indexOf ( const E &  value) const
inlinevirtual

Returns the index of the first occurrence of the specified element in this list, or -1 if this list does not contain the element.

More formally, returns the lowest index i such that get(i) == value, or -1 if there is no such index.

Parameters
valueThe element to search for in this List.
Returns
the index of the first occurrence of the specified element in this list,
Exceptions
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.

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

Reimplemented in decaf::util::StlList< E >, decaf::util::ArrayList< E >, decaf::util::ArrayList< ServiceListener * >, decaf::util::ArrayList< Pointer< ActiveMQDestination > >, decaf::util::LinkedList< E >, 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 * >, and decaf::util::LinkedList< cms::Connection * >.

template<typename E>
virtual int decaf::util::AbstractList< E >::lastIndexOf ( const E &  value) const
inlinevirtual

Returns the index of the last occurrence of the specified element in this list, or -1 if this list does not contain the element.

More formally, returns the highest index i such that get(i) == value or -1 if there is no such index.

Parameters
valueThe element to search for in this List.
Returns
the index of the last occurrence of the specified element in this list.
Exceptions
NullPointerExceptionif the Collection is a container of pointers and does not allow NULL values.

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

Reimplemented in decaf::util::StlList< E >, decaf::util::ArrayList< E >, decaf::util::ArrayList< ServiceListener * >, decaf::util::ArrayList< Pointer< ActiveMQDestination > >, decaf::util::LinkedList< E >, 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 * >, and decaf::util::LinkedList< cms::Connection * >.

template<typename E>
virtual ListIterator<E>* decaf::util::AbstractList< E >::listIterator ( int  index)
inlinevirtual
Parameters
indexindex of first element to be returned from the list iterator (by a call to the next method).
Returns
a list iterator of the elements in this list (in proper sequence), starting at the specified position in this list. The specified index indicates the first element that would be returned by an initial call to next. An initial call to previous would return the element with the specified index minus one.
Exceptions
IndexOutOfBoundsExceptionif the index is out of range (index < 0 || index > size())

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

Reimplemented in decaf::util::LinkedList< E >, 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::StlList< E >, decaf::util::AbstractSequentialList< E >, decaf::util::AbstractSequentialList< cms::MessageConsumer * >, decaf::util::AbstractSequentialList< CompositeTask * >, decaf::util::AbstractSequentialList< URI >, decaf::util::AbstractSequentialList< Pointer< MessageDispatch > >, decaf::util::AbstractSequentialList< Pointer< DestinationInfo > >, decaf::util::AbstractSequentialList< PrimitiveValueNode >, decaf::util::AbstractSequentialList< decaf::net::URI >, decaf::util::AbstractSequentialList< Pointer< Command > >, decaf::util::AbstractSequentialList< cms::MessageProducer * >, decaf::util::AbstractSequentialList< cms::Destination * >, decaf::util::AbstractSequentialList< cms::Session * >, and decaf::util::AbstractSequentialList< cms::Connection * >.

template<typename E>
virtual ListIterator<E>* decaf::util::AbstractList< E >::listIterator ( int index  ) const
inlinevirtual
template<typename E>
virtual E decaf::util::AbstractList< E >::removeAt ( int index  index)
inlinevirtual
template<typename E>
void decaf::util::AbstractList< E >::removeRange ( int  start,
int  end 
)
inlineprotected
template<typename E>
virtual E decaf::util::AbstractList< E >::set ( int index  DECAF_UNUSED,
const E &element  DECAF_UNUSED 
)
inlinevirtual

Field Documentation

template<typename E>
int decaf::util::AbstractList< E >::modCount
protected

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