ZXFoundation™ 26h2
Loading...
Searching...
No Matches
lib::list_head Struct Referenceexport
module lib.list

Intrusive circular doubly-linked list. More...

Collaboration diagram for lib::list_head:
[legend]

Data Structures

struct  typed_range
 Typed range that yields Owner& for range-for. More...

Public Member Functions

constexpr auto begin () const noexcept -> list_iterator
constexpr auto begin () noexcept -> list_iterator
 Raw bidirectional begin iterator.
constexpr auto count () const noexcept -> usize
 Returns the number of elements. O(N) — avoid hot paths.
constexpr auto empty () const noexcept -> bool
 Returns true if the list contains no elements.
constexpr auto end () const noexcept -> list_iterator
constexpr auto end () noexcept -> list_iterator
 Raw bidirectional end iterator (sentinel).
constexpr auto insert_before (list_node &marker, list_node &node) noexcept -> void
 Insert node immediately before marker.
template<typename Owner, list_node Owner::* member>
constexpr auto iter () noexcept -> typed_range< Owner, member >
 Return a typed range adaptor for range-for over Owner&.
 list_head (const list_head &)=delete
 list_head (list_head &&)=delete
auto operator= (const list_head &)=delete
auto operator= (list_head &&)=delete
constexpr auto pop_front () noexcept -> list_node *
 Remove and return the first element, or nullptr if empty.
constexpr auto push_back (list_node &node) noexcept -> void
 Append node (new last element).
constexpr auto push_front (list_node &node) noexcept -> void
 Prepend node (new first element).
constexpr auto singular () const noexcept -> bool
 Returns true if the list contains exactly one element.
constexpr auto splice_back (list_head &src) noexcept -> void
 Move all elements of src to the back of this list.

Static Public Member Functions

static constexpr auto remove (list_node &node) noexcept -> void
 Remove node from this list.

Data Fields

list_node sentinel

Detailed Description

Intrusive circular doubly-linked list.

Member Function Documentation

◆ insert_before()

auto lib::list_head::insert_before ( list_node & marker,
list_node & node )->void
inlineconstexprexportnoexcept

Insert node immediately before marker.

Parameters
[in]markerA node already linked into this list. Behavior is undefined if marker is the sentinel of a different list_head.
[in]nodeThe node to insert; must not be linked.

◆ pop_front()

auto lib::list_head::pop_front ( ) ->list_node *
inlineconstexprexportnoexcept

Remove and return the first element, or nullptr if empty.

Returns
Pointer to the removed list_node, or nullptr.

◆ push_back()

auto lib::list_head::push_back ( list_node & node) ->void
inlineconstexprexportnoexcept

Append node (new last element).

Parameters
[in,out]nodeMust not already be linked into any list.

◆ push_front()

auto lib::list_head::push_front ( list_node & node) ->void
inlineconstexprexportnoexcept

Prepend node (new first element).

Parameters
[in,out]nodeMust not already be linked into any list.
Warning
Double-insertion silently corrupts both lists.

◆ remove()

constexpr auto lib::list_head::remove ( list_node & node) ->void
inlinestaticconstexprexportnoexcept

Remove node from this list.

Parameters
[in,out]nodeNode to remove.

◆ splice_back()

auto lib::list_head::splice_back ( list_head & src) ->void
inlineconstexprexportnoexcept

Move all elements of src to the back of this list.

Parameters
[in,out]srcSource list. Must not be *this.
Warning
Splicing a list into itself corrupts the list.

The documentation for this struct was generated from the following file: