LinkedList Class Reference

#include <coherence/util/LinkedList.hpp>

Inherits AbstractList.

List of all members.


Detailed Description

A linked list implementation of List.

Author:
nsa 2008.02.04

Public Types

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

Public Member Functions

virtual bool add (size32_t i, Object::Holder oh)
 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

virtual bool addAll (size32_t i, Collection::View vc)
 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

virtual Object::Holder get (size32_t i) const
 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

virtual size32_t indexOf (Object::View v) const
 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

virtual size32_t lastIndexOf (Object::View v) const
 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

virtual
ListIterator::Handle 
listIterator (size32_t index=0) const
 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

virtual
ListMuterator::Handle 
listIterator (size32_t index=0)
 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

virtual Object::Holder remove (size32_t index)
 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

virtual Object::Holder set (size32_t index, Object::Holder oh)
 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

virtual List::View subList (size32_t fromIndex, size32_t toIndex) const
 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

virtual List::Handle subList (size32_t fromIndex, size32_t toIndex)
 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

virtual size32_t size () const
 Return the number of elements in this collection.

Returns:
the number of elements in this collection

virtual Iterator::Handle iterator () const
 Return an Iterator over this collection.

Returns:
an Iterator over this collection

virtual Muterator::Handle iterator ()
 Return an Iterator over this collection.

Returns:
an Iterator over this collection

virtual bool add (Object::Holder oh)
 Add the given element to this collection.

Parameters:
oh the element to add
Returns:
true iff this collection was modified as a result of this operation

This implementation will throw a coherence::lang::UnsupportedOperationException

virtual bool addAll (Collection::View vc)
 Add all elements from the supplied collection to this collection.

Parameters:
vCol the collection of elements to add
Returns:
true iff this collection was modified as a result of this operation
Exceptions:
coherence::lang::NullPointerException if the specified collection is NULL
See also:
add()

This implementation will throw a coherence::lang::UnsupportedOperationException unless add() is overridden (assuming the specified collection is non-empty).

virtual bool remove (Object::View v)
 Remove the supplied element from this collection.

Parameters:
v the element to remove
Returns:
true iff this collection was modified as a result of this operation

This implementation will throw a coherence::lang::UnsupportedOperationException unless add() is overridden (assuming the specified collection is non-empty).

virtual bool removeAll (Collection::View vColl)
 Remove all instances of the elements in the supplied collection from this collection.

Upon completion, contains() on this collection will return false for all elements in the supplied collection.

Parameters:
vCol the collection of elements to remove
Returns:
true iff this collection was modified as a result of this operation
Exceptions:
coherence::lang::NullPointerException if the specified collection is NULL
See also:
remove()

contains()

This implementation will throw a coherence::lang::UnsupportedOperationException} unless remove() is overridden (assuming the specified collection is non-empty).

virtual bool retainAll (Collection::View vCol)
 Remove all elements from this collection that are not present in the supplied collection.

Parameters:
vCol the collection of elements to retain
Returns:
true iff this collection was modified as a result of this operation.
Exceptions:
coherence::lang::NullPointerException if the specified collection is NULL
See also:
remove()

contains()

This implementation will throw a coherence::lang::UnsupportedOperationException unless remove() is overridden (assuming there are items to be removed by the operation).

virtual void clear ()
 Remove all elements from this collection.

This implementation will throw a coherence::lang::UnsupportedOperationException.


Protected Member Functions

 LinkedList ()
 Create a new LinkedList.
 LinkedList (Collection::View vc)
 Create a new LinkedList that has a reference to every element in the supplied collection.
virtual void assertIndex (size32_t i) const
 Helper method that will throw a coherence::lang::IndexOutOfBoundsException if the supplied index is out of range.

Protected Attributes

size32_t m_cElements
 The number of elements in the list.
MemberHandle
< ListElement
m_hHead
 The head of the list.
MemberHandle
< ListElement
m_hTail
 The tail of the list.

Classes

class  ListElement
 ListElement is the foundation element for the linked list. More...
class  SubLinkedList
 Utility class to implement a SubList of a LinkedList. More...

Constructor & Destructor Documentation

LinkedList (  )  [protected]

Create a new LinkedList.

Returns:
a new LinkedList

LinkedList ( Collection::View  vc  )  [protected]

Create a new LinkedList that has a reference to every element in the supplied collection.

Parameters:
vc The collection to base the LinkedList on
Returns:
a new LinkedList


Member Function Documentation

virtual void assertIndex ( size32_t  i  )  const [protected, virtual]

Helper method that will throw a coherence::lang::IndexOutOfBoundsException if the supplied index is out of range.

Parameters:
i the index to test


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