dkh.container.stack

  • Declaration

    struct Stack(T);

    Stack

    Examples

    1. import std.algorithm : equal; import std.range.primitives : isRandomAccessRange; import std.container.util : make; auto q = Stack!int(); assert(equal(q[], new int[0])); q.insertBack(1); assert(equal(q[], [1])); q.insertBack(2); assert(equal(q[], [1, 2])); q.insertBack(3); assert(equal(q[], [1, 2, 3])); q.removeBack(); assert(equal(q[], [1, 2])); q.insertBack(4); assert(equal(q[], [1, 2, 4])); q.removeBack(); assert(equal(q[], [1, 2]));

    • Declaration

      this(U)(U[] values...) if (isImplicitlyConvertible!(U, T));

      Stack(1, 2, 3)

    • Declaration

      this(Range)(Range r) if (isInputRange!Range && isImplicitlyConvertible!(ElementType!Range, T) && !is(Range == T[]));

      Stack(iota(3))

    • Declaration

      const @property bool empty();

    • Declaration

      const @property size_t length();
      alias opDollar = length;

    • Declaration

      inout @property inout(T)[] data();

    • Declaration

      inout ref inout(T) opIndex(size_t i);

    • Declaration

      inout ref inout(T) front();

    • Declaration

      inout ref inout(T) back();

    • Declaration

      void clear();

    • Declaration

      void insertBack(T item);
      template opOpAssign(string op : "~")
      alias stableInsertBack = insertBack;

    • Declaration

      void removeBack();
      alias stableRemoveBack = removeBack;

    • Declaration

      alias Range = RangeT!(StackPayload!T);
      alias ConstRange = RangeT!(const(StackPayload!T));
      alias ImmutableRange = RangeT!(immutable(StackPayload!T));

      Random-access range

    • Declaration

      const size_t[2] opSlice(size_t dim : 0)(size_t start, size_t end);

    • Declaration

      Range opIndex(size_t[2] rng);
      const ConstRange opIndex(size_t[2] rng);
      immutable ImmutableRange opIndex(size_t[2] rng);
      inout auto opIndex();

      Get slice