DoubleLinkedList-Node

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.

Summary
DoubleLinkedList-NodeDefines node type dlist_node_t which can be stored in a list of type dlist_t.
CopyrightThis program is free software.
Files
C-kern/api/ds/inmem/node/dlist_node.hHeader file DoubleLinkedList-Node.
Types
struct dlist_node_tExport dlist_node_t into global namespace.
dlist_node_tProvides the means for linking an object to two others of the same type.
nextPoints to next node in the list.
prevPoints to previous node in the list.
lifetime
dlist_node_INITStatic initializer.
generic
genericcast_dlistnodeCasts node into pointer to dlist_node_t.
inline implementation
Macros
genericcast_dlistnodeImplements dlist_node_t.genericcast_dlistnode.

Copyright

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.

Author

© 2012 Jörg Seebohn

Files

C-kern/api/ds/inmem/node/dlist_node.h

Types

struct dlist_node_t

typedef struct dlist_node_t dlist_node_t

Export dlist_node_t into global namespace.

dlist_node_t

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.

Summary
nextPoints to next node in the list.
prevPoints to previous node in the list.
lifetime
dlist_node_INITStatic initializer.
generic
genericcast_dlistnodeCasts node into pointer to dlist_node_t.

next

dlist_node_t * next

Points to next node in the list.  If this node is currently not part of any list this value is set to NULL.

prev

dlist_node_t * prev

Points to previous node in the list.  If this node is currently not part of any list this value is set to NULL.

lifetime

dlist_node_INIT

#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.

Note

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.

generic

genericcast_dlistnode

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.

Macros

genericcast_dlistnode

struct dlist_node_t
Provides the means for linking an object to two others of the same type.
struct dlist_t
Double linked circular list.
Defines node type dlist_node_t which can be stored in a list of type dlist_t.
typedef struct dlist_node_t dlist_node_t
Export dlist_node_t into global namespace.
dlist_node_t * next
Points to next node in the list.
dlist_node_t * prev
Points to previous node in the list.
#define dlist_node_INIT { 0, 0 }
Static initializer.
dlist_node_t * genericcast_dlistnode(void *node)
Casts node into pointer to dlist_node_t.
Close