It is a concrete class that defines a fast single linked list. This is a standard data structure that may be used with Last-In-First-Out policies. Use it if you need O(1) time costs for insertions and deletions in the head and tail, but can afford O(n) for searching from first to last element. It cannot iterate from last to first element as gcgDOUBLELINKEDLIST does. 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. Use the gcgLINKEDLIST::getIterator() method to obtain an iterator for the list from head to tail elements. Use gcgQUEUE if you need synchronized and exclusive accesses in enqueue and dequeue operations.
More...
|
| gcgLINKEDLIST () |
| Constructs a valid and empty linked list. More...
|
|
virtual | ~gcgLINKEDLIST () |
| 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(n) operation because the list is single linked. 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 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. The traversal order for this data structure is from head to tail elements (traversemode is ignored). 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 gcgLINKEDLIST::detach() MUST be used to delete all the nodes or reinsert them into another data structure. The traversal order of the iterator is defined by the parameter traversemode. Currently, the traversal order for this data structure is from head to tail elements (traversemode is ignored). All resources currently used by the gcgLINKEDLIST 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. This is a O(1) operation. More...
|
|
bool | insertLast (gcgLINK *node) |
| Inserts a new entry node at the TAIL of the list. This is a O(1) operation. 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(n) operation because the list is single linked. More...
|
|
bool | moveToFirst (gcgLINK *node) |
| Move an entry node that is already in the list to its first position. This is a O(n) operation because the list is single linked. More...
|
|
bool | moveToLast (gcgLINK *node) |
| Move an entry node that is already in the list to its last position. This is a O(n) operation because the list is single linked. 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(n) operation because the list is single linked. More...
|
|
bool | remove (gcgLINK *node) |
| Removes an entry node from the linked list. The node is not deleted. This is a O(n) operation because the list is single linked. 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 single linked list. This is a standard data structure that may be used with Last-In-First-Out policies. Use it if you need O(1) time costs for insertions and deletions in the head and tail, but can afford O(n) for searching from first to last element. It cannot iterate from last to first element as gcgDOUBLELINKEDLIST does. 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. Use the gcgLINKEDLIST::getIterator() method to obtain an iterator for the list from head to tail elements. Use gcgQUEUE if you need synchronized and exclusive accesses in enqueue and dequeue operations.
- Since
- 0.02.133