use LinkedLists;


import LinkedLists;

This module provides a simple singly linked list.


This module is expected to change in the future.

record LinkedList

A singly linked list.


destroy must be called to reclaim any memory used by the list.

type eltType

The type of the data stored in every node.

var size: int

The number of nodes in the list.

proc length ref

Deprecated - please use LinkedList.size.

iter these()

Iterate over the list, yielding each element.

Yield type:eltType
proc ref append(e: eltType)

Append e to the list.

proc push_back(e: eltType)

Synonym for append.

proc append(e: eltType, es: eltType ...?k)

Append all of the supplied arguments to the list.

proc prepend(e: eltType)

Prepend e to the list.

proc push_front(e: eltType)

Synonym for prepend.

proc concat(l: LinkedList(eltType))

Append all the elements in l to the end of the list.

proc ref remove(x: eltType)

Remove the first encountered instance of x from the list. Does nothing if x is not present in the list.

proc pop_front(): eltType

Remove the first element from the list and return it. It is an error to call this function on an empty list.

proc destroy()

Delete every node in the list.

proc makeList(x ...?k)

Initialize a new LinkedList containing all of the supplied arguments.

Arguments:x : T – Every argument must be of type T.
Return type:LinkedList(T)