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

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.

Protected Member Functions

void removeRange (int start, int end)

Protected Attributes

int modCount

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 (  )  [inline, virtual]

Member Function Documentation

template<typename E>
virtual void decaf::util::AbstractList< E >::add ( int index  DECAF_UNUSED,
const E &element  DECAF_UNUSED 
) [inline, virtual]
template<typename E>
virtual bool decaf::util::AbstractList< E >::add ( const E &  value  )  [inline, virtual]

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:
value The reference to the element to add to this Collection.
Returns:
true if the element was added to this Collection.
Exceptions:
UnsupportedOperationExceptio if this is an unmodifiable collection.
NullPointerException if the Collection is a container of pointers and does not allow NULL values.
IllegalArgumentException if some property of the element prevents it from being added to this collection
IllegalStateException if the element cannot be added at this time due to insertion restrictions.

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

Reimplemented in decaf::util::ArrayList< E >, decaf::util::LinkedList< E >, decaf::util::StlList< 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 * >, 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 bool decaf::util::AbstractList< E >::addAll ( int  index,
const Collection< E > &  source 
) [inline, virtual]

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:
index The index at which to insert the first element from the specified collection
source The Collection containing elements to be added to this list
Returns:
true if this list changed as a result of the call
Exceptions:
IndexOutOfBoundsException if the index given is less than zero or greater than the List size.
UnsupportedOperationExceptio if this is an unmodifiable collection.
NullPointerException if the Collection is a container of pointers and does not allow NULL values.
IllegalArgumentException if some property of the element prevents it from being added to this collection
IllegalStateException if the element cannot be added at this time due to insertion restrictions.

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

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

template<typename E>
virtual void decaf::util::AbstractList< 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

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

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

template<typename E>
virtual int decaf::util::AbstractList< E >::indexOf ( const E &  value  )  const [inline, virtual]

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:
value The element to search for in this List.
Returns:
the index of the first occurrence of the specified element in this list,
Exceptions:
NullPointerException if the Collection is a container of pointers and does not allow NULL values.

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

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

template<typename E>
virtual Iterator<E>* decaf::util::AbstractList< E >::iterator (  )  const [inline, virtual]
template<typename E>
virtual Iterator<E>* decaf::util::AbstractList< E >::iterator (  )  [inline, virtual]
template<typename E>
virtual int decaf::util::AbstractList< E >::lastIndexOf ( const E &  value  )  const [inline, virtual]

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:
value The element to search for in this List.
Returns:
the index of the last occurrence of the specified element in this list.
Exceptions:
NullPointerException if the Collection is a container of pointers and does not allow NULL values.

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

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

template<typename E>
virtual ListIterator<E>* decaf::util::AbstractList< E >::listIterator ( int index   )  const [inline, virtual]
template<typename E>
virtual ListIterator<E>* decaf::util::AbstractList< E >::listIterator ( int  index  )  [inline, virtual]
Parameters:
index index 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:
IndexOutOfBoundsException if the index is out of range (index < 0 || index > size())

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

Reimplemented in decaf::util::AbstractSequentialList< E >, decaf::util::LinkedList< E >, decaf::util::StlList< 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 * >, decaf::util::AbstractSequentialList< cms::Connection * >, 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 (  )  const [inline, virtual]
template<typename E>
virtual ListIterator<E>* decaf::util::AbstractList< E >::listIterator (  )  [inline, virtual]
template<typename E>
virtual E decaf::util::AbstractList< E >::removeAt ( int index  index  )  [inline, virtual]
template<typename E>
void decaf::util::AbstractList< E >::removeRange ( int  start,
int  end 
) [inline, protected]
template<typename E>
virtual E decaf::util::AbstractList< E >::set ( int index  DECAF_UNUSED,
const E &element  DECAF_UNUSED 
) [inline, virtual]

Field Documentation

template<typename E>
int decaf::util::AbstractList< E >::modCount [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