![]() |
The Simons
|
#include <List.h>
Inheritance diagram for List:
A List is a kind of Sequence that stores its elements in a chain of linked cells. List is the more efficient kind Sequence to use if elements are frequently inserted and removed at the front or middle of the List. If elements are only inserted and removed at the back, or accessed randomly, then a Vector should be used instead. A List is indexed from 0..n-1 where n is the size() of the List. Traversing a List in the forwards direction is efficient. If elements are visited in reverse, or random order, then a Vector should be used instead. A chain of links is used to store elements and new links are created and deleted on demand.
Public Member Functions | |
List () | |
Construct an empty List. | |
virtual | ~List () |
Release a List. | |
List (CollectionID) | |
Copy this List from another Collection. | |
virtual ObjectID | clone () const |
Clone a dynamic shallow copy of this List. | |
Natural | size () const |
Return the size of this List. | |
virtual ObjectID | first () const |
Return the first Object in this List. | |
virtual Void | addFirst (ObjectID) |
Add an Object to the front of this List. | |
virtual Void | removeFirst () |
Remove an Object from the front of this List. | |
virtual ObjectID | getAt (Integer) const |
Get the Object at an indexed position. | |
virtual Void | putAt (Integer, ObjectID) |
Replace an Object at an indexed position. | |
virtual Void | addAt (Integer, ObjectID) |
Insert an Object at an indexed position. | |
virtual Void | removeAt (Integer) |
Remove an Object at an indexed position. |
|
Construct an empty List. Allocates a dummy link as the head of the List, to reduce the number of null pointer checks and to make insertions and deletions more efficient.
|
|
Release a List. Walks through the links from the head and deletes each link. |
|
Copy this List from another Collection. Allocates a dummy link as the head of the List, then uses addAll() to include the other Collection.
|
|
Insert an Object at an indexed position. Splices in a new link at the index position, such that all existing elements from the index position to the end of the List are displaced upward. This is efficient for repeated insertions at the same index, or at continuously incrementing indices. To splice another Sequence into this List, iterate through its elements with item() and insert them at an incrementing index. To splice another Sequence in reverse order, insert all of its elements at the same index in this List. May throw an OutOfBounds exception if the index is out of bounds.
Reimplemented from Sequence. |
|
Add an Object to the front of this List. More efficient implementation than the inherited version.
Reimplemented from Sequence. |
|
Clone a dynamic shallow copy of this List. The resulting List manages a separate chain of links, but shares the Object elements of this List.
Reimplemented from Object. |
|
Return the first Object in this List. More efficient implementation than the inherited version. May throw an OutOfBounds exception, if the List is empty.
Reimplemented from Sequence. |
|
Get the Object at an indexed position. May throw an OutOfBounds exception, if the index is out of bounds.
Reimplemented from Sequence. |
|
Replace an Object at an indexed position. May throw an OutOfBounds exception, if the index is out of bounds.
Reimplemented from Sequence. |
|
Remove an Object at an indexed position. Excises a link at the index position, such that all existing elements above the index position to the end of the List are displaced downward. This is efficient for repeated removals at the same index. To excise a sub - Sequence from this List, remove elements repeatedly at the same index in this List. May raise an OutOfRange exception, if the index is out of bounds. Reimplemented from Sequence. |
|
Remove an Object from the front of this List. More efficient implementation than the inherited version. May throw an OutOfBounds exception, if the List is empty. Reimplemented from Sequence. |
|
Return the size of this List. Returns the length of the List.
Reimplemented from Collection. |