SingleLinkedList-Node

Defines node type slist_node_t which can be stored in a list of type slist_t.  Management overhead of objects which wants to be stored in a slist_t.

Summary
SingleLinkedList-NodeDefines node type slist_node_t which can be stored in a list of type slist_t.
CopyrightThis program is free software.
Files
C-kern/api/ds/inmem/node/slist_node.hHeader file of SingleLinkedList-Node.
Types
struct slist_node_tExports slist_node_t.
slist_node_tProvides the means for linking an object to another of the same type.
nextPoints to next node in the list.
lifetime
slist_node_INITStatic initializer.
generic
slist_node_EMBEDAllows to embed members of slist_node_t into another structure.

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/slist_node.h

Header file of SingleLinkedList-Node.

Types

struct slist_node_t

typedef struct slist_node_t slist_node_t

Exports slist_node_t.

slist_node_t

struct slist_node_t

Provides the means for linking an object to another of the same type.  This kind of object is managed by the single linked list object slist_t.  The next node can be reached from this node in O(1).  An object which wants to be member of a list must inherit from slist_node_t.

Summary
nextPoints to next node in the list.
lifetime
slist_node_INITStatic initializer.
generic
slist_node_EMBEDAllows to embed members of slist_node_t into another structure.

next

struct slist_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.

lifetime

slist_node_INIT

#define slist_node_INIT { 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.  This ensures that a node is not inserted in more than one list by mistake.

generic

slist_node_EMBED

#define slist_node_EMBED(name_nextptr) slist_node_t * name_nextptr

Allows to embed members of slist_node_t into another structure.

Parameter

name_nextptrThe name of the embedded slist_node_t.next member.

Your object must inherit or embed slist_node_t to be manageable by slist_t.  With macro slist_node_EMBED you can do

struct object_t {
   ... ;
   // declares: slist_node_t * next ;
   slist_node_EMBED(next) ;
}

// instead of
struct object_t {
   ... ;
   slist_node_t listnode ;
}
struct slist_node_t
Provides the means for linking an object to another of the same type.
Defines node type slist_node_t which can be stored in a list of type slist_t.
typedef struct slist_node_t slist_node_t
Exports slist_node_t.
struct slist_node_t * next
Points to next node in the list.
#define slist_node_INIT { 0 }
Static initializer.
#define slist_node_EMBED(name_nextptr) slist_node_t * name_nextptr
Allows to embed members of slist_node_t into another structure.
Close