Om
1.0.0
A universal framework for multimedia simulation
|
A doubly-linked list class. More...
#include <omLinkedList.h>
Classes | |
class | ConstIterator |
Iterator class for a linked list which can't modify it. More... | |
class | Iterator |
Iterator class for a linked list. More... | |
class | Node |
The class for a linked list node. More... | |
Public Member Functions | |
LinkedList () | |
Create a new empty linked list with no elements. More... | |
LinkedList (const LinkedList< T > &linkedList) | |
Create a deep copy of an existing linked list. More... | |
LinkedList< T > & | operator= (const LinkedList< T > &linkedList) |
Assign this linked list with the contents of another, performing a deep copy. More... | |
~LinkedList () | |
Destroy a linked list, deallocating all resourced used. More... | |
void | add (const T &newElement) |
Add an element to the end of the list. More... | |
Bool | insert (Index index, const T &newElement) |
Insert an element at the specified index of the list. More... | |
Bool | set (Index index, const T &newElement) |
Set an element at the specified index of the list to a new value. More... | |
Bool | removeAtIndex (Index index) |
Remove the element at the specified index from this list. More... | |
Bool | remove (T element) |
Remove the first element equal to the parameter element. More... | |
Bool | removeLast () |
Remove the last element in the linked list. More... | |
Bool | removeFirst () |
Remove the first element in the linked list. More... | |
void | clear () |
Remove all elements from the linked list. More... | |
T & | get (Index index) |
Return the element at the specified index. More... | |
const T & | get (Index index) const |
Return the element at the specified index. More... | |
T & | getFirst () |
Return a reference to the first element in the array list. More... | |
const T & | getFirst () const |
Return a const reference to the first element in the array list. More... | |
T & | getLast () |
Return a reference to the last element in the array list. More... | |
const T & | getLast () const |
Return a const reference to the last element in the array list. More... | |
T & | operator() (Index index) |
Return the element at the specified index. More... | |
const T & | operator() (Index index) const |
Return the element at the specified index. More... | |
Bool | contains (const T &anElement) const |
Return whether or not the specified element is in this list. More... | |
Bool | isEmpty () const |
Return whether or not the linked list has any elements. More... | |
Size | getSize () const |
Get the number of elements in the linked list. More... | |
Iterator | getIterator () |
Return an iterator for the linked list. More... | |
ConstIterator | getIterator () const |
Return a const iterator for the linked list. More... | |
A doubly-linked list class.
This class has an interface much like that of the class ArrayList, but it's implementation differs in that this class stores it's array elements non-contiguously in memory, which allows for faster insertion than an array-based list if the Iterator is used. However, the class is mostly useless other than that because an array-based list outperforms it in almost every other comparison. Essentially, it is not recommended that one uses this class unless it's quick insertion time while using the Iterator will be taken advantage of.
|
inline |
Create a new empty linked list with no elements.
|
inline |
Create a deep copy of an existing linked list.
|
inline |
Destroy a linked list, deallocating all resourced used.
|
inline |
Assign this linked list with the contents of another, performing a deep copy.
|
inline |
Add an element to the end of the list.
newElement | - the new element to add to the end of the list |
|
inline |
Insert an element at the specified index of the list.
If the index is out of the valid indices for the linked list, the method fails and FALSE is returned. Otherwise TRUE is returned.
newElement | - the new element to insert in the list |
index | - the index at which to insert the new element |
|
inline |
Set an element at the specified index of the list to a new value.
If the index is out of then valid indices for the linked list, the method fails and FALSE is returned.. Otherwise, the list element at the specified index is set to a new value, and TRUE is returned.
index | - the index at which to set the new element |
newElement | - the new element to set in the list |
|
inline |
Remove the element at the specified index from this list.
If the index is within the bounds of the list, then the list element at that index is removed and the method succeeds, returning TRUE. Otherwise, the method fails and FALSE is returned.
index | - the index of the list element to remove |
|
inline |
Remove the first element equal to the parameter element.
If this element is found, then it is removed and TRUE is returned. Otherwise, FALSE is returned and the list is unaffected.
element | - the list element to remove the first instance of |
|
inline |
Remove the last element in the linked list.
If the linked list has elements remaining in it, then the last element in the linked list is removed and TRUE is returned. Otherwise the list is unmodified and FALSE is returned.
|
inline |
Remove the first element in the linked list.
If the linked list has elements remaining in it, then the first element in the linked list is removed and TRUE is returned. Otherwise the list is unmodified and FALSE is returned.
|
inline |
Remove all elements from the linked list.
|
inline |
Return the element at the specified index.
If the specified index is not within the valid bounds of the linked list, then an exception is thrown indicating an index out of bounds error occurred. This is the non-const version of the get() method, allowing modification of the element.
index | - the index of the desired element. |
|
inline |
Return the element at the specified index.
If the specified index is not within the valid bounds of the array list, then an exception is thrown indicating an index out of bounds error occurred. This is the const version of the get() method, disallowing modification of the element.
index | - the index of the desired element. |
|
inline |
Return a reference to the first element in the array list.
|
inline |
Return a const reference to the first element in the array list.
|
inline |
Return a reference to the last element in the array list.
|
inline |
Return a const reference to the last element in the array list.
|
inline |
Return the element at the specified index.
If the specified index is not within the valid bounds of the linked list, then an exception is thrown indicating an index out of bounds error occurred. This is the const version of the operator (), disallowing modification of the element.
index | - the index of the desired element. |
|
inline |
Return the element at the specified index.
If the specified index is not within the valid bounds of the linked list, then an exception is thrown indicating an index out of bounds error occurred. This is the const version of the operator (), disallowing modification of the element.
index | - the index of the desired element. |
|
inline |
Return whether or not the specified element is in this list.
|
inline |
Return whether or not the linked list has any elements.
|
inline |
Get the number of elements in the linked list.
|
inline |
Return an iterator for the linked list.
The iterator serves to provide a way to efficiently iterate over the elements of the linked list and to perform modifications to the structure without incurring O(n) overhead for inserting or removing elements.
|
inline |
Return a const iterator for the linked list.
The iterator serves to provide a way to efficiently iterate over the elements of the linked list without incurring O(n) overhead. The returned iterator cannot modify the linked list.