containers.slist

Singly-linked list.

Authors

Brian Schott

  • Declaration

    struct SList(T, Allocator = Mallocator, bool supportGC = shouldAddGCRange!T);

    Single-linked allocator-backed list.

    Parameters

    T

    the element type

    Allocator

    the allocator to use. Defaults to Mallocator.

    supportGC

    true if the container should support holding references to GC-allocated memory.

    • Declaration

      this();

      No default construction if an allocator must be provided.

    • Declaration

      this(Allocator allocator);

      Use the given allocator for allocations.

    • Declaration

      inout @property auto front(this This)();

      Complexity: O(1)

      Return Value

      the most recently inserted item

    • Declaration

      inout @property auto back(this This)();

      Complexity: O(length)

      Return Value

      the least recently inserted item.

    • Declaration

      T moveFront();

      Removes the first item in the list.

      Complexity: O(1)

      Return Value

      the first item in the list.

    • Declaration

      void popFront();

      Removes the first item in the list.

      Complexity: O(1)

    • Declaration

      inout pure nothrow @nogc @property @safe bool empty();

      Complexity: O(1)

      Return Value

      true if this list is empty

    • Declaration

      inout pure nothrow @nogc @property @safe size_t length();

      Complexity: O(1)

      Return Value

      the number of items in the list

    • Declaration

      @trusted void insertFront(T t);
      alias insert = insertFront;
      alias insertAnywhere = insertFront;
      alias put = insertFront;

      Inserts an item at the front of the list.

      Complexity: O(1)

      Parameters

      T t

      the item to insert into the list

    • Declaration

      void opOpAssign(string op)(T t) if (op == "~");

      Supports list ~= item syntax

      Complexity: O(1)

    • Declaration

      @trusted bool remove(V)(V value);

      Removes the first instance of value found in the list.

      Complexity: O(length)

      Return Value

      true if a value was removed.

    • Declaration

      inout auto opSlice(this This)();

      Forward range interface

    • Declaration

      void clear();

      Removes all elements from the range

      Complexity: O(length)