#include <list.h>
Public Member Functions | |
ListItem (void) | |
Regular Constructor. | |
bool | Empty (void) const |
Is list empty? | |
void | Reinitialize (void) |
Reinitialize list item. | |
void | Unlink (void) |
Unlink and reinitialize. | |
void | UnlinkOnly (void) |
Unlink without reinitializing. | |
ListItem * | UnlinkNext (void) |
Unlink and reinitialize successor. | |
ListItem * | UnlinkNextOnly (void) |
Unlink successor without reinitializing. | |
void | PrependItem (ListItem &item) |
Insert a single item immediately after this element. | |
void | AppendItem (ListItem &item) |
Insert a single item immediately before this element. | |
void | SpliceAfter (ListItem &before_first, ListItem &last) |
Insert a sublist immediately after this element. | |
void | SpliceBefore (ListItem &before_first, ListItem &last) |
Insert a sublist immediately before this element. | |
void | PrependItemsFrom (ListItem &source) |
Prepends all elements of a list into this. | |
void | AppendItemsFrom (ListItem &source) |
Appends all elements of a list into this. | |
int | Length () const |
Compute the length of a list. | |
void | SpliceInto (ListItem &head, ListItem &cut_start) |
Deprecated. | |
void | SpliceIntoEnd (ListItem &head, ListItem &cut_start) |
Deprecated. | |
Public Attributes | |
ListItem * | next |
List member pointer. |
ListItem is a cheap knockoff of the Linux struct list_head embeddable doubly linked list structure. It works almost identically. All methods are bonehead simple and do very little work, and are declared inline.
ListItem implements a doubly-linked-list, with O(1) insertions and removals. Very simple and versatile. Basic sorting algorithms, including MergeSort and RadixSort, are also provided through the ListMergeSort and ListRadixSort classes.
ListItem includes methods to make it useful as both an item structure and a list head structure.
Lists may also be used in a loop fashion without a start pointer, although it can be trickier.
ListItem | ( | void | ) | [inline] |
Regular Constructor.
Initializes the list as a circular loop of one.
bool Empty | ( | void | ) | const [inline] |
Is list empty?
Checks whether the list is an empty circular loop.
true | next points to this and prev points to this | |
false | The list is linked with other ListItems. |
void Reinitialize | ( | void | ) | [inline] |
Reinitialize list item.
Be careful with this, as it can corrupt things if the item is linked!
void Unlink | ( | void | ) | [inline] |
Unlink and reinitialize.
Unlink the ListItem from whatever list it is linked to and reinitialize it to an empty circular list.
void UnlinkOnly | ( | void | ) | [inline] |
ListItem* UnlinkNext | ( | void | ) | [inline] |
Unlink and reinitialize successor.
Unlink the successor element, reinitialize it, and return a pointer.
ListItem* UnlinkNextOnly | ( | void | ) | [inline] |
Unlink successor without reinitializing.
Similar to UnlinkNext(), but skips reinitializing the unlinked list.
void PrependItem | ( | ListItem & | item | ) | [inline] |
Insert a single item immediately after this element.
Links another ListItem to this ListItem's circular list, such that the new ListItem becomes this element's immediate successor. If this element is considered to be the head of a list, whereas item is considered to be an item, then item is prepended to the list headed by this.
item | ListItem to be inserted. |
void AppendItem | ( | ListItem & | item | ) | [inline] |
Insert a single item immediately before this element.
Links another ListItem to this ListItem's circular list, such that the new ListItem becomes this element's immediate predecessor. If this element is considered to be the head of a list, whereas item is considered to be an item, then item is appended to the list headed by this.
item | ListItem to be inserted. |
void PrependItemsFrom | ( | ListItem & | source | ) | [inline] |
Prepends all elements of a list into this.
Splices all items of source onto the beginning of the subject list. The parameter source is reinitialized as part of this operation. Upon return, source will be empty.
source | List from which items should be transferred. |
void AppendItemsFrom | ( | ListItem & | source | ) | [inline] |
Appends all elements of a list into this.
Splices all items of source onto the end of the subject list. The parameter source is reinitialized as part of this operation. Upon return, source will be empty.
source | List from which items should be transferred. |
int Length | ( | ) | const [inline] |
Compute the length of a list.
Determines how many items are linked into a list, not including the ListItem it is called on.