It is a concrete class that defines a fast double linked list. This is a standard data structure that may be used with First-In-First-Out or Last-In-First-Out policies. Use it if you need O(1) time costs for insertions and deletions at head and tail, but can afford O(n) for searching. You must use gcgDOUBLELINK or its specializations in all methods. A drawback of using linked lists is their tendency to fragment memory and have low cache hits during searches. These problems can be avoided using arrays. This class can iterate from first to last element and vice-versa. Use the gcgDOUBLELINKEDLIST::getIterator() method to obtain an iterator for the list to span the nodes from head to tail or vice-versa. Use gcgLINKEDLIST if you need a simpler single linked lists which can be only spanned from head to tail.
More...
|
| gcgDOUBLELINKEDLIST () |
| Constructs a valid and empty linked list. More...
|
|
virtual | ~gcgDOUBLELINKEDLIST () |
| Destroys the linked list, releasing the list of nodes. All entries are deleted. More...
|
|
gcgLINK * | dequeueFirst () |
| Returns the first entry stored in the linked list. The entry is removed from the top of the list. This is a O(1) operation. More...
|
|
gcgLINK * | dequeueLast () |
| Returns the last entry stored in the linked list. The entry is removed from the end of the list. This is a O(1) operation. More...
|
|
uintptr_t | getCounter () |
| Returns the number of elements stored in the list. More...
|
|
bool | deleteAll () |
| Deletes and removes all entries from the linked list. All list resources are also released. More...
|
|
gcgITERATOR * | getIterator (int traversemode=0) |
| Returns an iterator for traversing the nodes of the linked list. The traversal order is defined by the parameter traversemode. Currently, there are two modes implemented: traversemode = 0, for head to tail iteration (default); and traversemode = 1, to iterate from tail to head. The linked list must not be changed by insertions, removals or moves while the iterator is being used. You must delete the returned iterator after use. The iterator copies a minimal information from the data structure. Note that deleting a iterator does not affect the nodes. More...
|
|
gcgITERATOR * | detach (int traversemode=0) |
| Force the list to be empty. It has the same effect as removing all entries from the linked list but keeping their chaining (which will used by the returned iterator). The nodes are NOT deleted. In order to retrieve the detached nodes, a gcgITERATOR is returned. This is useful to process the nodes freely and without the possible restrictions of the underlying data strucuture. Thus, the gcgITERATOR returned by gcgDOUBLELINKEDLIST::detach() MUST be used to delete all the nodes or reinsert them in another data structure. The traversal order of the returned iterator is defined by the parameter traversemode. Currently, there are two modes implemented: traversemode = 0, for head to tail iteration (default); and traversemode = 1, to iterate from tail to head. All resources currently used by the gcgDOUBLELINKEDLIST are released (becomes empty) but it can be reused normally. You must delete the gcgITERATOR after its use. More...
|
|
bool | insertFirst (gcgLINK *node) |
| Inserts a new entry node at the HEAD of the list. The node will have a NULL left/previous link. More...
|
|
bool | insertLast (gcgLINK *node) |
| Inserts a new entry node at the TAIL of the list. The node will have a NULL right/next link. More...
|
|
bool | insertAfter (gcgLINK *newnode, gcgLINK *node) |
| Inserts a new entry newnode in the list, after an existent entry pointed by node. This is a O(1) operation. More...
|
|
bool | insertBefore (gcgLINK *newnode, gcgLINK *node) |
| Inserts a new entry newnode in the list, before an existent entry pointed by node. This is a O(1) operation. More...
|
|
bool | moveToFirst (gcgLINK *node) |
| Move an entry node that is already in the list to its first position. The node will have a NULL previous link. This is a O(1) operation. More...
|
|
bool | moveToLast (gcgLINK *node) |
| Move an entry node that is already in the list to its last position. The node will have a NULL next link. This is a O(1) operation. More...
|
|
bool | switchNodes (gcgLINK *node1, gcgLINK *node2) |
| Switches the position of two existent elements of the linked list. The two nodes must be part of the list. This is a O(1) operation. More...
|
|
bool | remove (gcgLINK *node) |
| Removes an entry node from the linked list. The node is not deleted. This is a O(1) operation. More...
|
|
void * | operator new (size_t size) |
| Defines a new operator to be used by instatiations of GCGlib classes instead the global one. More...
|
|
void * | operator new (size_t size, const std::nothrow_t &) throw () |
| Defines a new operator to be used by instantiations of GCGlib classes instead the global one. Returns a NULL pointer instead of throwing an exception if an error occurs. More...
|
|
void * | operator new[] (size_t size) |
| Defines a new operator to be used by GCGlib array allocations instead the global one. More...
|
|
void * | operator new[] (size_t size, const std::nothrow_t &) throw () |
| Defines a new operator to be used by vector allocations instead the global one. More...
|
|
void | operator delete (void *p) |
| Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More...
|
|
void | operator delete (void *p, const std::nothrow_t &) throw () |
| Defines a delete operator to free instances of GCGlib classes instead the global one. It is designed to match the new operator. More...
|
|
void | operator delete[] (void *p) |
| Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More...
|
|
void | operator delete[] (void *p, const std::nothrow_t &) throw () |
| Defines a delete operator to free instances of arrays for GCGlib classes instead the global one. It is designed to match the new[] operator. More...
|
|
It is a concrete class that defines a fast double linked list. This is a standard data structure that may be used with First-In-First-Out or Last-In-First-Out policies. Use it if you need O(1) time costs for insertions and deletions at head and tail, but can afford O(n) for searching. You must use gcgDOUBLELINK or its specializations in all methods. A drawback of using linked lists is their tendency to fragment memory and have low cache hits during searches. These problems can be avoided using arrays. This class can iterate from first to last element and vice-versa. Use the gcgDOUBLELINKEDLIST::getIterator() method to obtain an iterator for the list to span the nodes from head to tail or vice-versa. Use gcgLINKEDLIST if you need a simpler single linked lists which can be only spanned from head to tail.
- Since
- 0.02.113