Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
slink.H File Reference

Singly linked list base class. More...

#include <aleph.H>
#include <cstddef>
#include <cstdint>
Include dependency graph for slink.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::Slink
 Singly linked handle to list nodes. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Macros

#define SLINK_TO_TYPE(type_name, link_name)
 Generate a conversion function from the link name to the enclosing structure.
 

Detailed Description

Singly linked list base class.

Low-level singly linked node without data. Base for Snode.

See also
tpl_snode.H Typed singly linked node
Author
Leandro Rabindranath León

Definition in file slink.H.

Macro Definition Documentation

◆ SLINK_TO_TYPE

#define SLINK_TO_TYPE (   type_name,
  link_name 
)
Value:
static type_name * slink_to_type(Slink * link) \
{ \
size_t offset_link = (size_t) &(ptr_zero->link_name); \
unsigned long address_type = ((unsigned long) link) - offset_link; \
}
DynList< T > maps(const C &c, Op op)
Classic map operation.

Generate a conversion function from the link name to the enclosing structure.

The function name is literally the parameter provided as link_name.

This macro is useful whenever a structure stores two or more Slink members and we need to retrieve the owning structure from a given link pointer.

For example: struct Registro { ... Slink l1; Slink l2; ... };

Then SLINK_TO_TYPE(Registro, l1) and SLINK_TO_TYPE(Registro, l2) produce the following functions:

  1. Registro * l1_to_type(Slink * link), which receives a pointer to the field l1 and returns the pointer to the owning record.
  2. Registro * l2_to_type(Slink * link), which receives a pointer to the field l2 and returns the pointer to the owning record.

The goal is to have naming schemes that allow distinguishing the different link fields.

Parameters
type_nametype of the enclosing structure (struct or class)
link_namename of the link field inside the structure

Definition at line 160 of file slink.H.