List

Usage

use List;

This module provides a simple singly linked list.

Warning

This module has been deprecated - please use LinkedLists instead.

record list

A singly linked list.

Note

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

type eltType

The type of the data stored in every node.

var length: int

The number of nodes in the list.

proc size

Synonym for length.

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: list(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 list containing all of the supplied arguments.

Arguments:x : T -- Every argument must be of type T.
Return type:list(T)