Skip to content
FutureBlitz

    Install

    Import std.collections.linked_list

    LinkedList

    std.collections.linked_list

    class

    @DebugElements Public Class LinkedList<T> Implements Iterable<T>, Cloneable, Defaultable

    A doubly linked list, which inserts and removes anywhere it has a node without moving the rest.

    Examples

    Local list = LinkedList<String>()
    Local b = list.Add("b")
    list.AddFirst("a")
    list.AddAfter(b, "c")
    Expect(list.ToArray() == ["a", "b", "c"])
    list.RemoveNode(b)
    Expect(list.ToArray() == ["a", "c"])
    Expect(b.List == Null)

    std/collections/linked_list.fb, line 69

    • Public Property Count: Int property #

      How many values it holds.

    • Public Property FirstNode: LinkedListNode<T>? property #

      The first node, or Null when the list is empty.

    • Public Property LastNode: LinkedListNode<T>? property #

      The last node, or Null when the list is empty.

    • @PanicsAtCaller Public Method First(): T method #

      The first value. Panics when the list is empty.

    • @PanicsAtCaller Public Method Last(): T method #

      The last value. Panics when the list is empty.

    • Public Method TryFirst(): T? method #

      The first value, or Null when the list is empty.

    • Public Method TryLast(): T? method #

      The last value, or Null when the list is empty.

    • Public Method AddFirst(value: T): LinkedListNode<T> method #

      Adds the value at the start, and gives its node.

    • Public Method AddLast(value: T): LinkedListNode<T> method #

      Adds the value at the end, and gives its node.

    • Public Method Add(value: T): LinkedListNode<T> method #

      The same as AddLast.

    • Public Method AddAll(values: Iterable<T>) method #

      Adds each of the values at the end, in order, all read first.

    • @PanicsAtCaller Public Method AddBefore(node: LinkedListNode<T>, value: T): LinkedListNode<T> method #

      Adds the value just before node, which has to be in this list, and gives its node.

    • @PanicsAtCaller Public Method AddAfter(node: LinkedListNode<T>, value: T): LinkedListNode<T> method #

      Adds the value just after node, which has to be in this list, and gives its node.

    • @PanicsAtCaller Public Method RemoveNode(node: LinkedListNode<T>) method #

      Takes node, which has to be in this list, out of it.

    • Public Method Remove(value: T): Bool method #

      Takes out the first value equal to value, and tells whether there was one.

    • @PanicsAtCaller Public Method RemoveFirst(): T method #

      Takes the first value out and gives it. Panics when the list is empty.

    • @PanicsAtCaller Public Method RemoveLast(): T method #

      Takes the last value out and gives it. Panics when the list is empty.

    • Public Method TryRemoveFirst(): T? method #

      Takes the first value out and gives it, or Null when the list is empty.

    • Public Method TryRemoveLast(): T? method #

      Takes the last value out and gives it, or Null when the list is empty.

    • Public Method NodeOf(value: T): LinkedListNode<T>? method #

      The first node whose value is equal to value, or Null.

    • Public Method LastNodeOf(value: T): LinkedListNode<T>? method #

      The last node whose value is equal to value, or Null.

    • Public Method Contains(value: T): Bool method #

      Whether it holds value.

    • Public Method Find(test: Func(T): Bool): T? method #

      The first value that test says is the one, or Null.

    • Public Method FindLast(test: Func(T): Bool): T? method #

      The last value that test says is the one, or Null.

    • Public Method Clear() method #

      Takes every value out. Their nodes are no longer in a list.

    • Public Method ToArray(): T[] method #

      The values, first to last, in a new array.

    • Public Static Method DefaultValue(): LinkedList<T> static method #

      A new, empty LinkedList.

    • Public Method Clone(): LinkedList<T> method #

      A new LinkedList with the same values, in nodes of its own.

    • Public Method Iterate(): LinkedListIterator<T> method #

      The values, first to last. Setting a node's Value while going over them is fine, but adding or removing one panics.

    Report an issue with this page or with FutureBlitz on GitHub.