Rudiments
|
Public Member Functions | |
linkedlist () | |
~linkedlist () | |
void | prepend (valuetype value) |
void | prepend (linkedlistnode< valuetype > *node) |
void | append (valuetype value) |
void | append (linkedlistnode< valuetype > *node) |
void | insertBefore (linkedlistnode< valuetype > *node, valuetype value) |
void | insertBefore (linkedlistnode< valuetype > *node, linkedlistnode< valuetype > *newnode) |
void | insertAfter (linkedlistnode< valuetype > *node, valuetype value) |
void | insertAfter (linkedlistnode< valuetype > *node, linkedlistnode< valuetype > *newnode) |
void | moveBefore (linkedlistnode< valuetype > *node, linkedlistnode< valuetype > *nodetomove) |
void | moveAfter (linkedlistnode< valuetype > *node, linkedlistnode< valuetype > *nodetomove) |
void | detach (linkedlistnode< valuetype > *node) |
bool | remove (valuetype value) |
bool | removeAndDelete (valuetype value) |
bool | removeAndArrayDelete (valuetype value) |
bool | removeAll (valuetype value) |
bool | removeAllAndDelete (valuetype value) |
bool | removeAllAndArrayDelete (valuetype value) |
bool | remove (linkedlistnode< valuetype > *node) |
bool | removeAndDelete (linkedlistnode< valuetype > *node) |
bool | removeAndArrayDelete (linkedlistnode< valuetype > *node) |
uint64_t | getLength () const |
linkedlistnode< valuetype > * | getFirst () |
linkedlistnode< valuetype > * | getLast () |
linkedlistnode< valuetype > * | getPrevious (linkedlistnode< valuetype > *node) |
linkedlistnode< valuetype > * | getNext (linkedlistnode< valuetype > *node) |
linkedlistnode< valuetype > * | find (valuetype value) |
linkedlistnode< valuetype > * | find (linkedlistnode< valuetype > *startnode, valuetype value) |
void | insertionSort () |
void | heapSort () |
void | clear () |
void | clearAndDelete () |
void | clearAndArrayDelete () |
void | print () const |
void | print (uint64_t count) const |
The linkedlist class allows you to store an arbitrary number of values in a doubly-linked list. Since the linkedlist class is template-based, you can store arbitrary types of values.
Each linkedlist is composed of a series of linkedlistnodes. Each linkedlistnode contains a value.
linkedlist< valuetype >::linkedlist | ( | ) |
Creates an empty instance of the linkedlist class.
linkedlist< valuetype >::~linkedlist | ( | ) |
Deletes this instance of the linkedlist class and all of its linkedlistnodes. Note however, that the value stored in each linkedlistnode is not deleted by this call.
void linkedlist< valuetype >::append | ( | linkedlistnode< valuetype > * | node | ) |
Appends already created linkedlistnode "node" to the linkedlist.
void linkedlist< valuetype >::append | ( | valuetype | value | ) |
Creates a new linkedlistnode containing "value" and appends it to the linkedlist.
void linkedlist< valuetype >::clear | ( | ) |
Deletes all linkedlistnodes currently in the linkedlist. Note however, that the value stored in each linkedlistnode is not deleted by this call.
void linkedlist< valuetype >::clearAndArrayDelete | ( | ) |
Deletes all linkedlistnodes currently in the linkedlist, deleting the value stored in each linkedlistnode as well, which is presumed to be an array.
void linkedlist< valuetype >::clearAndDelete | ( | ) |
Deletes all linkedlistnodes currently in the linkedlist, deleting the value stored in each linkedlistnode as well.
void linkedlist< valuetype >::detach | ( | linkedlistnode< valuetype > * | node | ) |
Detaches "node" from the list.
linkedlistnode<valuetype>* linkedlist< valuetype >::find | ( | linkedlistnode< valuetype > * | startnode, |
valuetype | value | ||
) |
Returns a pointer to the first linkedlistnode after "startnode" containing "value" or NULL if "value" was not found.
linkedlistnode<valuetype>* linkedlist< valuetype >::find | ( | valuetype | value | ) |
Returns a pointer to the first linkedlistnode containing "value" or NULL if "value" was not found.
linkedlistnode<valuetype>* linkedlist< valuetype >::getFirst | ( | ) |
Returns the first node in the linkedlist.
linkedlistnode<valuetype>* linkedlist< valuetype >::getLast | ( | ) |
Returns the last node in the linkedlist.
uint64_t linkedlist< valuetype >::getLength | ( | ) | const |
Returns the number of nodes in the linkedlist.
linkedlistnode<valuetype>* linkedlist< valuetype >::getNext | ( | linkedlistnode< valuetype > * | node | ) |
Returns the node after "node" or NULL if this node is the last node in the list. "node" is presumed to be in the list.
linkedlistnode<valuetype>* linkedlist< valuetype >::getPrevious | ( | linkedlistnode< valuetype > * | node | ) |
Returns the node prior to "node" or NULL if this node is the first node in the list. "node" is presumed to be in the list.
void linkedlist< valuetype >::heapSort | ( | ) |
Sorts the linkedlist in ascending order using a heap sort algorithm. This sort is faster than heapSort() but uses additional memory in proportion to the size of the list.
void linkedlist< valuetype >::insertAfter | ( | linkedlistnode< valuetype > * | node, |
linkedlistnode< valuetype > * | newnode | ||
) |
Inserts already created linkedlistnode "newnode" into the linkedlist after "node".
void linkedlist< valuetype >::insertAfter | ( | linkedlistnode< valuetype > * | node, |
valuetype | value | ||
) |
Creates a new linkedlistnode containing "value" and inserts it into the linkedlist after "node".
void linkedlist< valuetype >::insertBefore | ( | linkedlistnode< valuetype > * | node, |
linkedlistnode< valuetype > * | newnode | ||
) |
Inserts already created linkedlistnode "newnode" into the linkedlist before "node".
void linkedlist< valuetype >::insertBefore | ( | linkedlistnode< valuetype > * | node, |
valuetype | value | ||
) |
Creates a new linkedlistnode containing "value" and inserts it into the linkedlist before "node".
void linkedlist< valuetype >::insertionSort | ( | ) |
Sorts the linkedlist in ascending order using a modified insertion sort algorithm. This sort is slower than heapSort() but uses no additional memory.
void linkedlist< valuetype >::moveAfter | ( | linkedlistnode< valuetype > * | node, |
linkedlistnode< valuetype > * | nodetomove | ||
) |
Moves node "nodetomove" to the position after "node" in the linkedlist.
void linkedlist< valuetype >::moveBefore | ( | linkedlistnode< valuetype > * | node, |
linkedlistnode< valuetype > * | nodetomove | ||
) |
Moves node "nodetomove" to the position before "node" in the linkedlist.
void linkedlist< valuetype >::prepend | ( | linkedlistnode< valuetype > * | node | ) |
Prepends already created linkedlistnode "node" to the linkedlist.
void linkedlist< valuetype >::prepend | ( | valuetype | value | ) |
Creates a new linkedlistnode containing "value" and prepends it to the linkedlist.
void linkedlist< valuetype >::print | ( | ) | const |
Prints out a representation of the linkedlist.
void linkedlist< valuetype >::print | ( | uint64_t | count | ) | const |
Prints out a representation of the first "count" nodes of the linkedlist.
bool linkedlist< valuetype >::remove | ( | linkedlistnode< valuetype > * | node | ) |
Removed linkedlistnode "node" from the linkedlist.
Note that this operation does not require a search and is far less expensive than the remove(value) operation and removeAll().
Returns true on success and false on failure.
bool linkedlist< valuetype >::remove | ( | valuetype | value | ) |
Deletes the first linkedlistnode containing "value".
Note that this operation requires a search and is expensive in both execution time and code size.
Returns true on success and false on failure.
bool linkedlist< valuetype >::removeAll | ( | valuetype | value | ) |
Deletes all linkedlistnodes containing "value".
Note that this operation requires a search and is expensive in both execution time and code size.
Returns true on success and false on failure.
bool linkedlist< valuetype >::removeAllAndArrayDelete | ( | valuetype | value | ) |
Deletes all linkedlistnodes containing "value", deleting the values stored in the linkedlistnodes as well, which are presumed to be arrays.
Note that this operation requires a search and is expensive in both execution time and code size.
Returns true on success and false on failure.
bool linkedlist< valuetype >::removeAllAndDelete | ( | valuetype | value | ) |
Deletes all linkedlistnodes containing "value", deleting the values stored in the linkedlistnodes as well.
Note that this operation requires a search and is expensive in both execution time and code size.
Returns true on success and false on failure.
bool linkedlist< valuetype >::removeAndArrayDelete | ( | linkedlistnode< valuetype > * | node | ) |
Removed linkedlistnode "node" from the linkedlist, deleting the value stored in the linkedlistnode as well, which is presumed to be an array.
Note that this operation does not require a search and is far less expensive than the remove(value) operation and removeAll().
Returns true on success and false on failure.
bool linkedlist< valuetype >::removeAndArrayDelete | ( | valuetype | value | ) |
Deletes the first linkedlistnode containing "value", deleting the value stored in the linkedlistnode as well, which is presumed to be an array.
Note that this operation requires a search and is expensive in both execution time and code size.
Returns true on success and false on failure.
bool linkedlist< valuetype >::removeAndDelete | ( | linkedlistnode< valuetype > * | node | ) |
Removed linkedlistnode "node" from the linkedlist, deleting the value stored in the linkedlistnode as well.
Note that this operation does not require a search and is far less expensive than the remove(value) operation and removeAll().
Returns true on success and false on failure.
bool linkedlist< valuetype >::removeAndDelete | ( | valuetype | value | ) |
Deletes the first linkedlistnode containing "value", deleting the value stored in the linkedlistnode as well.
Note that this operation requires a search and is expensive in both execution time and code size.
Returns true on success and false on failure.