|
cons
|
Implements functions for manipulating cons nodes. More...
#include <cons_node.h>
Go to the source code of this file.
Macros | |
| #define | NODE_FROM_CELL(_cell_) ((struct cons_node *)((char *)(_cell_) - offsetof(struct cons_node, cell))) |
Functions | |
| static struct cons_node * | node_from_cell (struct cons *cell) |
| struct cons_node * | cons_car_node (struct cons_node *node) |
| Accessor for the parent node (super-node) of a cons node. | |
| struct cons_node * | cons_cdr_node (struct cons_node *node) |
| Accessor for the next sibling node of a cons node. | |
| struct cons_node * | cons_sub_node (struct cons_node *node) |
| Accessor for the first child node (sub-node) of a cons node. | |
| struct cons_node * | cons_node (struct cons_node *sub, struct cons_node *super) |
| Constructs a cons node with the specified sub-node and new super-node. | |
Implements functions for manipulating cons nodes.
This file implements functions for working with cons nodes, which are a specialised data structure built on top of cons cells. The functions allow for constructing a tree of cons nodes, where each node can have a parent (super-node) and a list of children (sub-nodes). The operations include linking and unlinking nodes in the tree structure, as well as accessing the parent and child nodes.
Definition in file cons_node.c.
| #define NODE_FROM_CELL | ( | _cell_ | ) | ((struct cons_node *)((char *)(_cell_) - offsetof(struct cons_node, cell))) |
Definition at line 26 of file cons_node.c.
Accessor for the parent node (super-node) of a cons node.
| node | The cons node to access. |
| Pointer | to the parent node, or NULL if there is no parent. |
Retrieves the parent node from the car field of the cons cell.
Definition at line 36 of file cons_node.c.
Accessor for the next sibling node of a cons node.
| node | The cons node to access. |
NULL if there is no next sibling node. cdr field of the node's cell. Up-casts the cdr field of the cons cell to a pointer to a node. Definition at line 38 of file cons_node.c.
Constructs a cons node with the specified sub-node and new super-node.
| sub | The sub-node to be linked. |
| super | The new super-node to be linked. |
Definition at line 45 of file cons_node.c.
Accessor for the first child node (sub-node) of a cons node.
| node | The cons node to access. |
NULL if there are no child nodes. head field of the cons node. Up-casts the head field to a pointer to a node. Definition at line 40 of file cons_node.c.
Definition at line 34 of file cons_node.c.