List Class Reference

#include <coherence/util/List.hpp>

Inherits Collection.

Inherited by AbstractList [virtual], and WrapperCollections::AbstractWrapperList [virtual].

List of all members.


Detailed Description

An ordered collection (also known as a sequence).

The user of this interface has precise control over where in the list each element is inserted. The user can access elements by their integer index (position in the list), and search for elements in the list. Unlike sets, lists typically allow duplicate elements.

The List interface places additional stipulations, beyond those specified in the Collection interface, on the contracts of the iterator, add, remove, equals, and hashCode methods.

See also:
Collection
Author:
js/nsa 2008.01.03

Public Types

typedef spec::Handle Handle
 List Handle definition.
typedef spec::View View
 List View definition.
typedef spec::Holder Holder
 List Holder definition.

Public Member Functions

virtual bool add (size32_t i, Object::Holder oh)=0
 Add the given element to this collection at the position specified.
virtual bool addAll (size32_t i, Collection::View vc)=0
 Add all the elements from the supplied collection to this collection at the position specified.
virtual Object::Holder get (size32_t i) const =0
 Return the element from the specified position in the list.
virtual size32_t indexOf (Object::View v) const =0
 Return the position in the list of the first instance of the specified element.
virtual size32_t lastIndexOf (Object::View v) const =0
 Return the position in this list of the last instance of the specified element.
virtual
ListIterator::Handle 
listIterator (size32_t i=0) const =0
 Return a ListIterator for this list starting at index.
virtual
ListMuterator::Handle 
listIterator (size32_t i=0)=0
 Return a ListIterator for this list starting at index.
virtual Object::Holder remove (size32_t i)=0
 Remove the element at the specified position in the list.
virtual Object::Holder set (size32_t i, Object::Holder oh)=0
 Replace the element at the specified position in this list with the specified element.
virtual List::View subList (size32_t iFrom, size32_t iTo) const =0
 Return a new list containing the contents of the list between the specified fromIndex (inclusive) and toIndex (exclusive).
virtual List::Handle subList (size32_t iFrom, size32_t iTo)=0
 Return a new list containing the contents of the list between the specified fromIndex (inclusive) and toIndex (exclusive).
virtual bool equals (Object::View vObj) const =0
 Compares the specified object with this list for equality.
virtual size32_t hashCode () const =0
 The hash code of a List is defined as follows: size32_t nHash = 1; for (Iterator::Handle hIter = list.iterator(); hIter->hasNext(); ) { Object::View v = hIter->next(); nHash = 31 * nHash + (NULL == v ? 0 : v->hashCode()); } This ensures that l1->equals(l2) implies that l1->hashCode() == l2->hashCode() for any two lists l1 and l2, as required by the general contract of Object::hashCode().

Static Public Attributes

static const size32_t npos
 The largest possible value of type size32_t.

Member Function Documentation

virtual bool add ( size32_t  i,
Object::Holder  oh 
) [pure virtual]

Add the given element to this collection at the position specified.

If an element is already at that position it will be shifted to the right by 1.

Parameters:
i the position to insert the element at
oh the element to add
Returns:
true iff this list was modified as a result of this operation
Exceptions:
coherence::lang::IndexOutOfBoundsException if the index is out of range

Implemented in LinkedList, SubList, and WrapperCollections::AbstractWrapperList.

virtual bool addAll ( size32_t  i,
Collection::View  vc 
) [pure virtual]

Add all the elements from the supplied collection to this collection at the position specified.

Parameters:
i the index of the list to add the elements to
vc the collection to add to this list
Returns:
true iff this list was modified as a result of this operation
Exceptions:
coherence::lang::IndexOutOfBoundsException if the inedex is out of range

Implemented in LinkedList, SubList, and WrapperCollections::AbstractWrapperList.

virtual Object::Holder get ( size32_t  i  )  const [pure virtual]

Return the element from the specified position in the list.

Parameters:
i the position of the item to return
Returns:
the element from the specified position in the list
Exceptions:
coherence::lang::IndexOutOfBoundsException if the index is out of range

Implemented in LinkedList, SubList, and WrapperCollections::AbstractWrapperList.

virtual size32_t indexOf ( Object::View  v  )  const [pure virtual]

Return the position in the list of the first instance of the specified element.

Parameters:
v The object in the list to return the index of
Returns:
the position of the object if found, or List::npos

Implemented in LinkedList, SubList, and WrapperCollections::AbstractWrapperList.

virtual size32_t lastIndexOf ( Object::View  v  )  const [pure virtual]

Return the position in this list of the last instance of the specified element.

Parameters:
v The element to search for in the list
Returns:
the position of the element if found, or List::npos

Implemented in LinkedList, SubList, and WrapperCollections::AbstractWrapperList.

virtual ListIterator::Handle listIterator ( size32_t  i = 0  )  const [pure virtual]

Return a ListIterator for this list starting at index.

Parameters:
i the index to start the ListIterator at
Returns:
a ListIterator for this list start at index

Implemented in LinkedList, SubList, TypedCollections::TypedList, and WrapperCollections::AbstractWrapperList.

virtual ListMuterator::Handle listIterator ( size32_t  i = 0  )  [pure virtual]

Return a ListIterator for this list starting at index.

Parameters:
i the index to start the ListIterator at
Returns:
a ListIterator for this list start at index

Implemented in LinkedList, SubList, TypedCollections::TypedList, and WrapperCollections::AbstractWrapperList.

virtual Object::Holder remove ( size32_t  i  )  [pure virtual]

Remove the element at the specified position in the list.

Parameters:
i the index from which to remove an element
Returns:
the element at the specified position prior to this operation
Exceptions:
coherence::lang::IndexOutOfBoundsException if the index is out of range

Implemented in LinkedList, SubList, and WrapperCollections::AbstractWrapperList.

virtual Object::Holder set ( size32_t  i,
Object::Holder  oh 
) [pure virtual]

Replace the element at the specified position in this list with the specified element.

Parameters:
i the position in the list to replace
oh the object to replace at the specified position
Returns:
the element at the specified position prior to this operation
Exceptions:
coherence::lang::IndexOutOfBoundsException if the index is out of range

Implemented in LinkedList, SubList, and WrapperCollections::AbstractWrapperList.

virtual List::View subList ( size32_t  iFrom,
size32_t  iTo 
) const [pure virtual]

Return a new list containing the contents of the list between the specified fromIndex (inclusive) and toIndex (exclusive).

Parameters:
iFrom the start position in this list to create the sublist from (inclusive).
iTo the end position in this list to end the sublist at (exclusive).
Returns:
the new sublist of this list

Implemented in LinkedList, LinkedList::SubLinkedList, and WrapperCollections::AbstractWrapperList.

virtual List::Handle subList ( size32_t  iFrom,
size32_t  iTo 
) [pure virtual]

Return a new list containing the contents of the list between the specified fromIndex (inclusive) and toIndex (exclusive).

Parameters:
iFrom the start position in this list to create the sublist from (inclusive).
iTo the end position in this list to end the sublist at (exclusive).
Returns:
the new sublist of this list

Implemented in LinkedList, LinkedList::SubLinkedList, and WrapperCollections::AbstractWrapperList.

virtual bool equals ( Object::View  vObj  )  const [pure virtual]

Compares the specified object with this list for equality.

Two lists are defined to be equal iff they contain the same elements in the same order. This definition ensures that the equals method works properly across different implementations of the List interface.

Parameters:
vObj the Object to be compared for equality with this list
Returns:
true if the specified Object is equal to this list.

Implemented in AbstractList, and WrapperCollections::AbstractWrapperList.

virtual size32_t hashCode (  )  const [pure virtual]

The hash code of a List is defined as follows: size32_t nHash = 1; for (Iterator::Handle hIter = list.iterator(); hIter->hasNext(); ) { Object::View v = hIter->next(); nHash = 31 * nHash + (NULL == v ? 0 : v->hashCode()); } This ensures that l1->equals(l2) implies that l1->hashCode() == l2->hashCode() for any two lists l1 and l2, as required by the general contract of Object::hashCode().

Returns:
the hash code value for this list

Reimplemented from Object.

Implemented in AbstractList, and WrapperCollections::AbstractWrapperList.


The documentation for this class was generated from the following file: Copyright (c) 2000-2008 Oracle. All rights reserved.