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

Singly linked list with typed nodes. More...

#include <ahDefs.H>
#include <tpl_snode.H>
#include <ah-errors.H>
Include dependency graph for tpl_slist.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Aleph::Slist< T >
 Singly linked list of nodes that store values of type T. More...
 
class  Aleph::Slist< T >::Iterator
 Iterator over singly linked nodes. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Detailed Description

Singly linked list with typed nodes.

This file provides Slist, a simple singly linked list where each node stores a value of type T. Designed for minimal memory overhead and simple forward traversal.

Key Features

  • One pointer per node (minimal overhead)
  • O(1) insertion at head
  • Forward traversal only
  • Move semantics support

Complexity

Operation Time
insert_first O(1)
remove_first O(1)
search O(n)
reverse O(n)

Usage Example

Slist<int> list;
list.insert_first(new Snode<int>(42));
list.insert_first(new Snode<int>(17));
for (auto it = list.get_first(); it != nullptr; it = it->get_next())
std::cout << it->get_data() << " ";

When to Use

  • Memory is extremely constrained
  • Only forward traversal needed
  • LIFO access pattern (stack-like)
See also
tpl_dnode.H Doubly linked nodes
tpl_dynDlist.H Full-featured doubly linked list
tpl_snode.H Node definition
Author
Leandro Rabindranath León

Definition in file tpl_slist.H.