Skip to content
FutureBlitz

    Install

    Import std.collections.linked_list

    std.collections.linked_list

    LinkedList<T>: values in a chain of nodes, each linked to the ones before and after it, so adding or removing one beside a node takes the same time however many there are. A node is the same object for as long as it's in the list, so code can keep one to add beside or remove later. Each node holds the one after it and, weakly, the one before, so the list makes no cycles, and Clear and the list's end unlink every node, so a node kept elsewhere holds none of the others.

    std/collections/linked_list.fb

    Types

    LinkedListNode class

    Public Class LinkedListNode<T>

    One value of a LinkedList, with the ones before and after it, which inserting and removing next to it go through.

    std/collections/linked_list.fb, line 13

    • Public Field Value: T field #

      Its value.

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

      The node after this one, or Null when it's the last or not in a list.

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

      The node before this one, or Null when it's the first or not in a list.

    • Public Property List: LinkedList<T>? property #

      The list it's in, or Null once it's removed.

    LinkedList 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.

    std/collections/linked_list.fb, line 43

    • 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.

    LinkedListIterator struct

    Public Struct LinkedListIterator<T> Implements Iterator<T>

    The values of a LinkedList, first to last, which For ... In goes over.

    std/collections/linked_list.fb, line 337

    Extends

    LinkedList extend

    Extend LinkedList<T> Implements Equatable

    No doc comment.

    std/collections/linked_list.fb, line 356

    LinkedList extend

    Extend LinkedList<T> Implements Printable

    No doc comment.

    std/collections/linked_list.fb, line 373

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