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

Doubly linked list node with typed data. More...

#include <type_traits>
#include <ahFunction.H>
#include <dlink.H>
#include <ah-errors.H>
Include dependency graph for tpl_dnode.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::Dnode< T >
 Node belonging to a double circular linked list with header node. More...
 
class  Aleph::Dnode< T >::Iterator
 Iterator on a list of Dnode objects. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Detailed Description

Doubly linked list node with typed data.

This file provides Dnode<T>, a node for circular doubly linked lists that inherits from Dlink. Each node stores a value of type T.

Key Features

  • Circular doubly linked structure
  • Inherits navigation from Dlink
  • O(1) insertion and removal
  • Bidirectional traversal

Memory Layout

+------+------+------+
| prev | next | data |
+------+------+------+
void next()
Advance all underlying iterators (bounds-checked).
Definition ah-zip.H:175

Complexity

Operation Time
insert_next/prev O(1)
remove_next/prev O(1)
get_data O(1)

Usage Example

Dnode<int> head; // Header node (sentinel)
head.insert_next(new Dnode<int>(42));
head.insert_next(new Dnode<int>(17));
// Traverse forward
for (auto* p = head.get_next(); p != &head; p = p->get_next())
std::cout << p->get_data() << " ";

Design Pattern

Uses a sentinel (header) node pattern: the list is never empty as the header always exists. This simplifies boundary conditions.

See also
dlink.H Base doubly linked structure
tpl_dynDlist.H High-level doubly linked list
tpl_snode.H Singly linked node alternative
Author
Leandro Rabindranath León

Definition in file tpl_dnode.H.