fn TailQueue(comptime T: type) type

A tail queue is headed by a pair of pointers, one to the head of the list and the other to the tail of the list. The elements are doubly linked so that an arbitrary element can be removed without a need to traverse the list. New elements can be added to the list before or after an existing element, at the head of the list, or at the end of the list. A tail queue may be traversed in either direction.

Parameters

T: type,

Fields

first: ?*Node = null,
last: ?*Node = null,
len: usize = 0,

Types

Functions

fn append(list: *Self, new_node: *Node) void

Insert a new node at the end of the list.

Insert a new node at the end of the list.

Arguments: new_node: Pointer to the new node to insert.

fn concatByMoving(list1: *Self, list2: *Self) void

Concatenate list2 onto the end of list1, removing all entries from the former.

Concatenate list2 onto the end of list1, removing all entries from the former.

Arguments: list1: the list to concatenate onto list2: the list to be concatenated

fn insertAfter(list: *Self, node: *Node, new_node: *Node) void

Insert a new node after an existing one.

Insert a new node after an existing one.

Arguments: node: Pointer to a node in the list. new_node: Pointer to the new node to insert.

fn insertBefore(list: *Self, node: *Node, new_node: *Node) void

Insert a new node before an existing one.

Insert a new node before an existing one.

Arguments: node: Pointer to a node in the list. new_node: Pointer to the new node to insert.

fn pop(list: *Self) ?*Node

Remove and return the last node in the list.

Remove and return the last node in the list.

Returns: A pointer to the last node in the list.

fn popFirst(list: *Self) ?*Node

Remove and return the first node in the list.

Remove and return the first node in the list.

Returns: A pointer to the first node in the list.

fn prepend(list: *Self, new_node: *Node) void

Insert a new node at the beginning of the list.

Insert a new node at the beginning of the list.

Arguments: new_node: Pointer to the new node to insert.

fn remove(list: *Self, node: *Node) void

Remove a node from the list.

Remove a node from the list.

Arguments: node: Pointer to the node to be removed.