# Module lists

Implementation of singly and doubly linked lists. Because it makes no sense to do so, the 'next' and 'prev' pointers are not hidden from you and can be manipulated directly for efficiency.

# Types

    TDoublyLinkedNode* {.pure, final.}[T] = object
      next*, prev*: ref TDoublyLinkedNode[T]
      value*: T

  a node a doubly linked list consists of

    PDoublyLinkedNode*[T] = ref TDoublyLinkedNode[T]

    TSinglyLinkedNode* {.pure, final.}[T] = object
      next*: ref TSinglyLinkedNode[T]
      value*: T

  a node a singly linked list consists of

    PSinglyLinkedNode*[T] = ref TSinglyLinkedNode[T]

    TSinglyLinkedList* {.pure, final.}[T] = object
      head*, tail*: PSinglyLinkedNode[T]

  a singly linked list

    TDoublyLinkedList* {.pure, final.}[T] = object
      head*, tail*: PDoublyLinkedNode[T]

  a doubly linked list

    TSinglyLinkedRing* {.pure, final.}[T] = object
      head*: PSinglyLinkedNode[T]

  a singly linked ring

    TDoublyLinkedRing* {.pure, final.}[T] = object
      head*: PDoublyLinkedNode[T]

  a doubly linked ring

# Procs

    proc initSinglyLinkedList*[T](): TSinglyLinkedList[T]

  creates a new singly linked list that is empty.

    proc initDoublyLinkedList*[T](): TDoublyLinkedList[T]

  creates a new doubly linked list that is empty.

    proc initSinglyLinkedRing*[T](): TSinglyLinkedRing[T]

  creates a new singly linked ring that is empty.

    proc initDoublyLinkedRing*[T](): TDoublyLinkedRing[T]

  creates a new doubly linked ring that is empty.

    proc newDoublyLinkedNode*[T](value: T): PDoublyLinkedNode[T]

  creates a new doubly linked node with the given value.

    proc newSinglyLinkedNode*[T](value: T): PSinglyLinkedNode[T]

  creates a new singly linked node with the given value.

    proc `$`*[T](L: TSinglyLinkedList[T]): string

  turns a list into its string representation.

    proc `$`*[T](L: TDoublyLinkedList[T]): string

  turns a list into its string representation.

    proc `$`*[T](L: TSinglyLinkedRing[T]): string

  turns a list into its string representation.

    proc `$`*[T](L: TDoublyLinkedRing[T]): string

  turns a list into its string representation.

    proc find*[T](L: TSinglyLinkedList[T]; value: T): PSinglyLinkedNode[T]

  searches in the list for a value. Returns nil if the value does not exist.

    proc find*[T](L: TDoublyLinkedList[T]; value: T): PDoublyLinkedNode[T]

  searches in the list for a value. Returns nil if the value does not exist.

    proc find*[T](L: TSinglyLinkedRing[T]; value: T): PSinglyLinkedNode[T]

  searches in the list for a value. Returns nil if the value does not exist.

    proc find*[T](L: TDoublyLinkedRing[T]; value: T): PDoublyLinkedNode[T]

  searches in the list for a value. Returns nil if the value does not exist.

    proc contains*[T](L: TSinglyLinkedList[T]; value: T): bool {.inline.}

  searches in the list for a value. Returns false if the value does not exist, true otherwise.

    proc contains*[T](L: TDoublyLinkedList[T]; value: T): bool {.inline.}

  searches in the list for a value. Returns false if the value does not exist, true otherwise.

    proc contains*[T](L: TSinglyLinkedRing[T]; value: T): bool {.inline.}

  searches in the list for a value. Returns false if the value does not exist, true otherwise.

    proc contains*[T](L: TDoublyLinkedRing[T]; value: T): bool {.inline.}

  searches in the list for a value. Returns false if the value does not exist, true otherwise.

    proc prepend*[T](L: var TSinglyLinkedList[T]; n: PSinglyLinkedNode[T]) {.inline.}

  prepends a node to L. Efficiency: O(1).

    proc prepend*[T](L: var TSinglyLinkedList[T]; value: T) {.inline.}

  prepends a node to L. Efficiency: O(1).

    proc append*[T](L: var TDoublyLinkedList[T]; n: PDoublyLinkedNode[T])

  appends a node n to L. Efficiency: O(1).

    proc append*[T](L: var TDoublyLinkedList[T]; value: T)

  appends a value to L. Efficiency: O(1).

    proc prepend*[T](L: var TDoublyLinkedList[T]; n: PDoublyLinkedNode[T])

  prepends a node n to L. Efficiency: O(1).

    proc prepend*[T](L: var TDoublyLinkedList[T]; value: T)

  prepends a value to L. Efficiency: O(1).

    proc remove*[T](L: var TDoublyLinkedList[T]; n: PDoublyLinkedNode[T])

  removes n from L. Efficiency: O(1).

    proc prepend*[T](L: var TSinglyLinkedRing[T]; n: PSinglyLinkedNode[T])

  prepends a node n to L. Efficiency: O(1).

    proc prepend*[T](L: var TSinglyLinkedRing[T]; value: T)

  prepends a value to L. Efficiency: O(1).

    proc append*[T](L: var TDoublyLinkedRing[T]; n: PDoublyLinkedNode[T])

  appends a node n to L. Efficiency: O(1).

    proc append*[T](L: var TDoublyLinkedRing[T]; value: T)

  appends a value to L. Efficiency: O(1).

    proc prepend*[T](L: var TDoublyLinkedRing[T]; n: PDoublyLinkedNode[T])

  prepends a node n to L. Efficiency: O(1).

    proc prepend*[T](L: var TDoublyLinkedRing[T]; value: T)

  prepends a value to L. Efficiency: O(1).

    proc remove*[T](L: var TDoublyLinkedRing[T]; n: PDoublyLinkedNode[T])

  removes n from L. Efficiency: O(1).

# Iterators

    iterator items*[T](L: TDoublyLinkedList[T]): T

  yields every value of L.

    iterator items*[T](L: TSinglyLinkedList[T]): T

  yields every value of L.

    iterator items*[T](L: TSinglyLinkedRing[T]): T

  yields every value of L.

    iterator items*[T](L: TDoublyLinkedRing[T]): T

  yields every value of L.

    iterator nodes*[T](L: TSinglyLinkedList[T]): PSinglyLinkedNode[T]

  iterates over every node of x. Removing the current node from the list during traversal is supported.

    iterator nodes*[T](L: TDoublyLinkedList[T]): PDoublyLinkedNode[T]

  iterates over every node of x. Removing the current node from the list during traversal is supported.

    iterator nodes*[T](L: TSinglyLinkedRing[T]): PSinglyLinkedNode[T]

  iterates over every node of x. Removing the current node from the list during traversal is supported.

    iterator nodes*[T](L: TDoublyLinkedRing[T]): PDoublyLinkedNode[T]

  iterates over every node of x. Removing the current node from the list during traversal is supported.

Generated: 2012-09-23 21:47:54 UTC