Defines node type dlist_node_t which can be stored in a list of type dlist_t. Management overhead of objects which wants to be stored in a dlist_t.
DoubleLinkedList-Node | Defines node type dlist_node_t which can be stored in a list of type dlist_t. |
Copyright | This program is free software. |
Files | |
C-kern/ | Header file DoubleLinkedList-Node. |
Types | |
struct dlist_node_t | Export dlist_node_t into global namespace. |
dlist_node_t | Provides the means for linking an object to two others of the same type. |
next | Points to next node in the list. |
prev | Points to previous node in the list. |
lifetime | |
dlist_node_INIT | Static initializer. |
generic | |
genericcast_dlistnode | Casts node into pointer to dlist_node_t. |
inline implementation | |
Macros | |
genericcast_dlistnode | Implements dlist_node_t.genericcast_dlistnode. |
This program is free software. You can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
© 2012 Jörg Seebohn
Header file DoubleLinkedList-Node.
typedef struct dlist_node_t dlist_node_t
Export dlist_node_t into global namespace.
struct dlist_node_t
Provides the means for linking an object to two others of the same type. This kind of object is managed by the double linked list object dlist_t. The next or previous node can be reached from this node in O(1). An object which wants to be member of a list must inherit from dlist_node_t.
next | Points to next node in the list. |
prev | Points to previous node in the list. |
lifetime | |
dlist_node_INIT | Static initializer. |
generic | |
genericcast_dlistnode | Casts node into pointer to dlist_node_t. |
#define dlist_node_INIT { 0, 0 }
Static initializer. Before inserting a node into a list do not forget to initialize the next pointer with NULL.
The next pointer is checked against NULL in the precondition of every insert function of every list implementation. The dlist_node_t.prev pointer is omitted from the check. This ensures that a node is not inserted in more than one list by mistake.
dlist_node_t * genericcast_dlistnode( void * node )
Casts node into pointer to dlist_node_t. The pointer node must point to an object which has the same data members as dlist_node_t.
Implements dlist_node_t.genericcast_dlistnode.
Provides the means for linking an object to two others of the same type.
struct dlist_node_t
Double linked circular list.
struct dlist_t
Export dlist_node_t into global namespace.
typedef struct dlist_node_t dlist_node_t
Points to next node in the list.
dlist_node_t * next
Points to previous node in the list.
dlist_node_t * prev
Static initializer.
#define dlist_node_INIT { 0, 0 }
Casts node into pointer to dlist_node_t.
dlist_node_t * genericcast_dlistnode( void * node )