D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Thu Sep 16 11:25:56 2010

# std.container

Defines generic containers.

License:
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at boost.org/LICENSE_1_0.txt).

Authors:
Andrei Alexandrescu

Container primitives. Below, C means a container type, c is a value of container type, l represents the effective length of value x, which could be a single element (in which case l is 1), a container, or a range.

Syntax | Ο(·) | Description
--- | --- | ---

Creates a container of type C from either another container or a range.

Returns a duplicate of the container.

Returns the concatenation of c and r. x may be a single element or an input range.

Returns the concatenation of x and c. x may be a single element or an input range type.

Iteration

c.Range |  | The primary range type associated with the container.

c[] | Returns a range iterating over the entire container, in a container-defined order.

Fetches a portion of the container from key a to key b.

Capacity

c.empty | 1 | Returns true if the container has no elements, false otherwise.

c.length | Returns the number of elements in the container.

Forces the number of elements in the container to n. If the container ends up growing, the added elements are initialized in a container-dependent manner (usually with T.init).

c.capacity | Returns the maximum number of elements that can be stored in the container without triggering a reallocation.

c.reserve(x) | l | Forces capacity to at least x without reducing it.

Access

Returns the first element of the container, in a container-defined order.

Destructively reads and returns the first element of the container. The slot is not removed from the container; it is left initalized with T.init. This routine need not be defined if front returns a ref.

Assigns v to the first element of the container.

Returns the last element of the container, in a container-defined order.

Destructively reads and returns the first element of the container. The slot is not removed from the container; it is left initalized with T.init. This routine need not be defined if front returns a ref.

Assigns v to the last element of the container.

Provides indexed access into the container. The index type is container-defined. A container may define several index types (and consequently overloaded indexing).

Destructively reads and returns the value at position x. The slot is not removed from the container; it is left initialized with T.init.

Sets element at specified index into the container.

Performs read-modify-write operation at specified index into the container.

Operations

Returns nonzero if e is found in c.

Returns a range of all elements strictly less than v.

Returns a range of all elements strictly greater than v.

Returns a range of all elements in c that are equal to v.

Modifiers

Appends x to c. x may be a single element or an input range type.

Removes all elements in c.

Inserts x in c at a position (or positions) chosen by c.

Same as c.insert(x), but is guaranteed to not invalidate any ranges.

Same as c.insert(v) but relaxes complexity to linear.

Same as c.stableInsert(v) but relaxes complexity to linear.

Removes some element from c and returns it.

Same as c.removeAny(v), but is guaranteed to not invalidate any iterators.

Inserts v at the front of c.

Same as c.insertFront(v), but guarantees no ranges will be invalidated.

Inserts v at the back of c.

Same as c.insertBack(v), but guarantees no ranges will be invalidated.

Removes the element at the front of c.

Same as c.removeFront(), but guarantees no ranges will be invalidated.

Removes the value at the back of c.

Same as c.removeBack(), but guarantees no ranges will be invalidated.

Removes range r from c.

Same as c.remove(r), but guarantees iterators are not invalidated.

Removes range r from c.

Same as c.linearRemove(r), but guarantees iterators are not invalidated.

Removes an element from c by using its key k. The key's type is defined by the container.

Container make(Container, T...)(T arguments);
Container make(Container, T...)(T arguments);
  Returns an initialized container. This function is mainly for eliminating construction differences between class containers and struct containers.

struct SList(T);
  Implements a simple and fast singly-linked list.

  template __ctor(U) if (isImplicitlyConvertible!(U,T))
    Constructor taking a number of nodes

  template __ctor(Stuff) if (isInputRange!(Stuff) && isImplicitlyConvertible!(ElementType!(Stuff),T) && !is(Stuff == T[]))
    Constructor taking an input range

  const bool opEquals(ref const SList rhs);
    Comparison for equality.

    Complexity:
    Ο(min(n, n1)) where n1 is the number of elements in rhs.

  struct Range;
    Defines the container's primary range, which embodies a forward range.

    const bool empty();
    Range save();
    T front();
    void front(T value);
    void popFront();
      Forward range primitives.

  const bool empty();
    Property returning true if and only if the container has no elements.

    Complexity:
    Ο(1)

  SList dup();
    Duplicates the container. The elements themselves are not transitively duplicated.

    Complexity:
    Ο(n).

  Range opSlice();
    Returns a range that iterates over all elements of the container, in forward order.

    Complexity:
    Ο(1)

  T front();
    Forward to opSlice().front.

    Complexity:
    Ο(1)

  void front(T value);
    Forward to opSlice().front(value).

    Complexity:
    Ο(1)

  template opBinary(string op,Stuff) if (op == "~" && is(typeof(SList(rhs))))
    Returns a new SList that's the concatenation of this and its argument. opBinaryRight is only defined if Stuff does not define opBinary.

    SList opBinary(Stuff rhs);
      Returns a new SList that's the concatenation of this and its argument. opBinaryRight is only defined if Stuff does not define opBinary.

  void clear();
    Removes all contents from the SList.

    Postcondition:
    empty

    Complexity:
    Ο(1)

  template insertFront(Stuff) if (isInputRange!(Stuff) && isImplicitlyConvertible!(ElementType!(Stuff),T))
  template insertFront(Stuff) if (isImplicitlyConvertible!(Stuff,T))
  alias insert;
  alias stableInsert;
  alias stableInsertFront;
    Inserts stuff to the front of the container. stuff can be a value convertible to T or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of elements inserted

    Complexity:
    Ο(log(n))

    size_t insertFront(Stuff stuff);
      Inserts stuff to the front of the container. stuff can be a value convertible to T or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

      Returns:
      The number of elements inserted

      Complexity:
      Ο(log(n))

  T removeAny();
  alias stableRemoveAny;
    Picks one value from the front of the container, removes it from the container, and returns it.

    Precondition:
    !empty

    Returns:
    The element removed.

    Complexity:
    Ο(1).

  void removeFront();
  alias stableRemoveFront;
    Removes the value at the front of the container. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Precondition:
    !empty

    Complexity:
    Ο(1).

  size_t removeFront(size_t howMany);
  alias stableRemoveFront;
    Removes howMany values at the front or back of the container. Unlike the unparameterized versions above, these functions do not throw if they could not remove howMany elements. Instead, if howMany > n, all elements are removed. The returned value is the effective number of elements removed. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of elements removed

    Complexity:
    Ο(howMany * log(n)).

  template insertAfter(Stuff)
    Inserts stuff after range r, which must be a range previously extracted from this container. Given that all ranges for a list end at the end of the list, this function essentially appends to the list and uses r as a potentially fast way to reach the last node in the list. (Ideally r is positioned near or at the last element of the list.)

    stuff can be a value convertible to T or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of values inserted.

    Complexity:
    Ο(k + m), where k is the number of elements in r and m is the length of stuff.

    size_t insertAfter(Range r, Stuff stuff);
      Inserts stuff after range r, which must be a range previously extracted from this container. Given that all ranges for a list end at the end of the list, this function essentially appends to the list and uses r as a potentially fast way to reach the last node in the list. (Ideally r is positioned near or at the last element of the list.)

      stuff can be a value convertible to T or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

      Returns:
      The number of values inserted.

      Complexity:
      Ο(k + m), where k is the number of elements in r and m is the length of stuff.

  template insertAfter(Stuff)
  alias stableInsertAfter;
    Similar to insertAfter above, but accepts a range bounded in count. This is important for ensuring fast insertions in the middle of the list. For fast insertions after a specified position r, use insertAfter(take(r, 1), stuff). The complexity of that operation only depends on the number of elements in stuff.

    Precondition:
    r.original.empty || r.maxLength > 0

    Returns:
    The number of values inserted.

    Complexity:
    Ο(k + m), where k is the number of elements in r and m is the length of stuff.

    size_t insertAfter(Take!(Range) r, Stuff stuff);
      Similar to insertAfter above, but accepts a range bounded in count. This is important for ensuring fast insertions in the middle of the list. For fast insertions after a specified position r, use insertAfter(take(r, 1), stuff). The complexity of that operation only depends on the number of elements in stuff.

      Precondition:
      r.original.empty || r.maxLength > 0

      Returns:
      The number of values inserted.

      Complexity:
      Ο(k + m), where k is the number of elements in r and m is the length of stuff.

  Range linearRemove(Range r);
    Removes a range from the list in linear time.

    Returns:
    An empty range.

    Complexity:
    Ο(n)

  Range linearRemove(Take!(Range) r);
  alias stableLinearRemove;
    Removes a Take!Range from the list in linear time.

    Returns:
    A range comprehending the elements after the removed range.

    Complexity:
    Ο(n)

struct Array(T) if (!is(T : const(bool)));
  Array type with deterministic control of memory. The memory allocated for the array is reclaimed as soon as possible; there is no reliance on the garbage collector. Array uses malloc and free for managing its own memory.

  const bool opEquals(ref const Array rhs);
    Comparison for equality.

  struct Range;
    Defines the container's primary range, which is a random-access range.

  const bool empty();
    Property returning true if and only if the container has no elements.

    Complexity:
    Ο(1)

  Array dup();
    Duplicates the container. The elements themselves are not transitively duplicated.

    Complexity:
    Ο(n).

  const size_t length();
    Returns the number of elements in the container.

    Complexity:
    Ο(1).

  size_t capacity();
    Returns the maximum number of elements the container can store without (a) allocating memory, (b) invalidating iterators upon insertion.

    Complexity:
    Ο(1)

  void reserve(size_t elements);
    Ensures sufficient capacity to accommodate e elements.

    Postcondition:
    capacity >= e

    Complexity:
    Ο(1)

  Range opSlice();
    Returns a range that iterates over elements of the container, in forward order.

    Complexity:
    Ο(1)

  Range opSlice(size_t a, size_t b);
    Returns a range that iterates over elements of the container from index a up to (excluding) index b.

    Precondition:
    a <= b && b <= length

    Complexity:
    Ο(1)

  const size_t opDollar();
    @@@BUG@@@ This doesn't work yet

  T front();
  void front(T value);
  T back();
  void back(T value);
    Forward to opSlice().front and opSlice().back, respectively.

    Precondition:
    !empty

    Complexity:
    Ο(1)

  T opIndex(size_t i);
  void opIndexAssign(T value, size_t i);
  template opIndexOpAssign(string op)
    Indexing operators yield or modify the value at a specified index.

    Precondition:
    i < length

    Complexity:
    Ο(1)

  template opBinary(string op,Stuff) if (op == "~")
    Returns a new container that's the concatenation of this and its argument. opBinaryRight is only defined if Stuff does not define opBinary.

    Complexity:
    Ο(n + m), where m is the number of elements in stuff

    Array opBinary(Stuff stuff);
      Returns a new container that's the concatenation of this and its argument. opBinaryRight is only defined if Stuff does not define opBinary.

      Complexity:
      Ο(n + m), where m is the number of elements in stuff

  template opOpAssign(string op,Stuff) if (op == "~")
    Forwards to insertBack(stuff).

    void opOpAssign(Stuff stuff);
      Forwards to insertBack(stuff).

  void clear();
    Removes all contents from the container. The container decides how capacity is affected.

    Postcondition:
    empty

    Complexity:
    Ο(n)

  void length(size_t newLength);
    Sets the number of elements in the container to newSize. If newSize is greater than length, the added elements are added to unspecified positions in the container and initialized with T.init.

    Complexity:
    Ο(abs(n - newLength))

    Postcondition:
    length == newLength

  T removeAny();
  alias stableRemoveAny;
    Picks one value in an unspecified position in the container, removes it from the container, and returns it. Implementations should pick the value that's the most advantageous for the container, but document the exact behavior. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Precondition:
    !empty

    Returns:
    The element removed.

    Complexity:
    Ο(log(n)).

  template insertBack(Stuff) if (isImplicitlyConvertible!(Stuff,T) || isInputRange!(Stuff) && isImplicitlyConvertible!(ElementType!(Stuff),T))
  alias insert;
    Inserts value to the front or back of the container. stuff can be a value convertible to T or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of elements inserted

    Complexity:
    Ο(m * log(n)), where m is the number of elements in stuff

    size_t insertBack(Stuff stuff);
      Inserts value to the front or back of the container. stuff can be a value convertible to T or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

      Returns:
      The number of elements inserted

      Complexity:
      Ο(m * log(n)), where m is the number of elements in stuff

  void removeBack();
  alias stableRemoveBack;
    Removes the value at the back of the container. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Precondition:
    !empty

    Complexity:
    Ο(log(n)).

  size_t removeBack(size_t howMany);
  alias stableRemoveBack;
    Removes howMany values at the front or back of the container. Unlike the unparameterized versions above, these functions do not throw if they could not remove howMany elements. Instead, if howMany > n, all elements are removed. The returned value is the effective number of elements removed. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of elements removed

    Complexity:
    Ο(howMany).

  template insertBefore(Stuff) if (isImplicitlyConvertible!(Stuff,T))
  template insertBefore(Stuff) if (isInputRange!(Stuff) && isImplicitlyConvertible!(ElementType!(Stuff),T))
  template insertAfter(Stuff)
  template replace(Stuff) if (isInputRange!(Stuff) && isImplicitlyConvertible!(ElementType!(Stuff),T))
  template replace(Stuff) if (isImplicitlyConvertible!(Stuff,T))
    Inserts stuff before, after, or instead range r, which must be a valid range previously extracted from this container. stuff can be a value convertible to T or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of values inserted.

    Complexity:
    Ο(n + m), where m is the length of stuff

    size_t insertBefore(Range r, Stuff stuff);
      Inserts stuff before, after, or instead range r, which must be a valid range previously extracted from this container. stuff can be a value convertible to T or a range of objects convertible to T. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

      Returns:
      The number of values inserted.

      Complexity:
      Ο(n + m), where m is the length of stuff

  Range linearRemove(Range r);
  alias stableLinearRemove;
    Removes all elements belonging to r, which must be a range obtained originally from this container. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    A range spanning the remaining elements in the container that initially were right after r.

    Complexity:
    Ο(n - m), where m is the number of elements in r

struct BinaryHeap(Store,alias less = "a < b") if (isRandomAccessRange!(Store) || isRandomAccessRange!(typeof(Store.init[])));
  Implements a binary heap container on top of a given random-access range type (usually T[]) or a random-access container type (usually Array!T). The documentation of BinaryHeap will refer to the underlying range or container as the store of the heap.

  The binary heap induces structure over the underlying store such that accessing the largest element (by using the front property) is a Ο(1) operation and extracting it (by using the removeFront() method) is done fast in Ο(log n) time.

  If less is the less-than operator, which is the default option, then BinaryHeap defines a so-called max-heap that optimizes extraction of the largest elements. To define a min-heap, instantiate BinaryHeap with "a > b" as its predicate.

  Simply extracting elements from a BinaryHeap container is tantamount to lazily fetching elements of Store in descending order. Extracting elements from the BinaryHeap to completion leaves the underlying store sorted in ascending order but, again, yields elements in descending order.

  If Store is a range, the BinaryHeap cannot grow beyond the size of that range. If Store is a container that supports insertBack, the BinaryHeap may grow by adding elements to the container.

  Example:

      // Example from "Introduction to Algorithms" Cormen et al, p 146
      int[] a = [ 4, 1, 3, 2, 16, 9, 10, 14, 8, 7 ];
      auto h = heapify(a);
      // largest element
      assert(h.front == 16);
      // a has the heap property
      assert(equal(a, [ 16, 14, 10, 9, 8, 7, 4, 3, 2, 1 ]));

  this(Store s, size_t initialSize = size_t.max);
    Converts the store s into a heap. If initialSize is specified, only the first initialSize elements in s are transformed into a heap, after which the heap can grow up to r.length (if Store is a range) or indefinitely (if Store is a container with insertBack). Performs Ο(min(r.length, initialSize)) evaluations of less.

  void acquire(Store s, size_t initialSize = size_t.max);
    Takes ownership of a store. After this, manipulating s may make the heap work incorrectly.

  void assume(Store s, size_t initialSize = size_t.max);
    Takes ownership of a store assuming it already was organized as a heap.

  bool empty();
    Returns true if the heap is empty, false otherwise.

  BinaryHeap dup();
    Returns a duplicate of the heap. The underlying store must also support a dup method.

  size_t length();
    Returns the length of the heap.

  size_t capacity();
    Returns the capacity of the heap, which is the length of the underlying store (if the store is a range) or the capacity of the underlying store (if the store is a container).

  ElementType!(Store) front();
    Returns a copy of the front of the heap, which is the largest element according to less.

  void clear();
    Clears the heap by detaching it from the underlying store.

  size_t insert(ElementType!(Store) value);
    Inserts value into the store. If the underlying store is a range and length == capacity, throws an exception.

  void removeFront();
    Removes the largest element from the heap.

  ElementType!(Store) removeAny();
    Removes the largest element from the heap and returns a copy of it. The element still resides in the heap's store. For performance reasons you may want to use removeFront with heaps of objects that are expensive to copy.

  void replaceFront(ElementType!(Store) value);
    Replaces the largest element in the store with value.

  bool conditionalInsert(ElementType!(Store) value);
    If the heap has room to grow, inserts value into the store and returns true. Otherwise, if less(value, front), calls replaceFront(value) and returns again true. Otherwise, leaves the heap unaffected and returns false. This method is useful in scenarios where the smallest k elements of a set of candidates must be collected.

BinaryHeap!(Store) heapify(Store)(Store s, size_t initialSize = size_t.max);
  Convenience function that returns a BinaryHeap!Store object initialized with s and initialSize.

struct Array(T) if (is(T == bool));
  Array specialized for bool. Packs together values efficiently by allocating one bit per element.

  struct Range;
    Defines the container's primary range.

    Range save();
    bool empty();
    T front();
    void front(bool value);
    T moveFront();
    void popFront();
    T back();
    T moveBack();
    void popBack();
    T opIndex(size_t i);
    void opIndexAssign(T value, uint i);
    T moveAt(size_t i);
    const ulong length();
      Range primitives

  bool empty();
    Property returning true if and only if the container has no elements.

    Complexity:
    Ο(1)

  Array!(bool) dup();
    Returns a duplicate of the container. The elements themselves are not transitively duplicated.

    Complexity:
    Ο(n).

  ulong length();
    Returns the number of elements in the container.

    Complexity:
    Ο(log(n)).

  ulong capacity();
    Returns the maximum number of elements the container can store without (a) allocating memory, (b) invalidating iterators upon insertion.

    Complexity:
    Ο(log(n)).

  void reserve(ulong e);
    Ensures sufficient capacity to accommodate n elements.

    Postcondition:
    capacity >= n

    Complexity:
    Ο(log(e - capacity)) if e > capacity, otherwise Ο(1).

  Range opSlice();
    Returns a range that iterates over all elements of the container, in a container-defined order. The container should choose the most convenient and fast method of iteration for opSlice().

    Complexity:
    Ο(log(n))

  Range opSlice(ulong a, ulong b);
    Returns a range that iterates the container between two specified positions.

    Complexity:
    Ο(log(n))

  bool front();
  void front(bool value);
  bool back();
  void back(bool value);
    Equivalent to opSlice().front and opSlice().back, respectively.

    Complexity:
    Ο(log(n))

  bool opIndex(ulong i);
  void opIndexAssign(bool value, ulong i);
  template opIndexOpAssign(string op)
  T moveAt(ulong i);
    Indexing operators yield or modify the value at a specified index.

  template opBinary(string op,Stuff) if (op == "~")
    Returns a new container that's the concatenation of this and its argument.

    Complexity:
    Ο(n + m), where m is the number of elements in stuff

    Array!(bool) opBinary(Stuff rhs);
      Returns a new container that's the concatenation of this and its argument.

      Complexity:
      Ο(n + m), where m is the number of elements in stuff

  template opOpAssign(string op,Stuff) if (op == "~")
    Forwards to insertAfter(this[], stuff).

    Array!(bool) opOpAssign(Stuff stuff);
      Forwards to insertAfter(this[], stuff).

  void clear();
    Removes all contents from the container. The container decides how capacity is affected.

    Postcondition:
    empty

    Complexity:
    Ο(n)

  void length(ulong newLength);
    Sets the number of elements in the container to newSize. If newSize is greater than length, the added elements are added to the container and initialized with ElementType.init.

    Complexity:
    Ο(abs(n - newLength))

    Postcondition:
    length == newLength

  alias insert;
  alias stableInsert;
    Inserts stuff in the container. stuff can be a value convertible to ElementType or a range of objects convertible to ElementType.

    The stable version guarantees that ranges iterating over the container are never invalidated. Client code that counts on non-invalidating insertion should use stableInsert.

    Returns:
    The number of elements added.

    Complexity:
    Ο(m * log(n)), where m is the number of elements in stuff

  alias linearInsert;
  alias stableLinearInsert;
    Same as insert(stuff) and stableInsert(stuff) respectively, but relax the complexity constraint to linear.

  T removeAny();
  alias stableRemoveAny;
    Picks one value in the container, removes it from the container, and returns it. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Precondition:
    !empty

    Returns:
    The element removed.

    Complexity:
    Ο(log(n))

  template insertBack(Stuff) if (is(Stuff : bool))
  template insertBack(Stuff) if (isInputRange!(Stuff) && is(ElementType!(Stuff) : bool))
  alias stableInsertBack;
    Inserts value to the back of the container. stuff can be a value convertible to ElementType or a range of objects convertible to ElementType. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of elements inserted

    Complexity:
    Ο(log(n))

    ulong insertBack(Stuff stuff);
      Inserts value to the back of the container. stuff can be a value convertible to ElementType or a range of objects convertible to ElementType. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

      Returns:
      The number of elements inserted

      Complexity:
      Ο(log(n))

  void removeBack();
  alias stableRemoveBack;
    Removes the value at the front or back of the container. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated. The optional parameter howMany instructs removal of that many elements. If howMany > n, all elements are removed and no exception is thrown.

    Precondition:
    !empty

    Complexity:
    Ο(log(n)).

  ulong removeBack(ulong howMany);
    Removes howMany values at the front or back of the container. Unlike the unparameterized versions above, these functions do not throw if they could not remove howMany elements. Instead, if howMany > n, all elements are removed. The returned value is the effective number of elements removed. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of elements removed

    Complexity:
    Ο(howMany * log(n)). ditto

  template insertBefore(Stuff)
  alias stableInsertBefore;
  template insertAfter(Stuff)
  alias stableInsertAfter;
  template replace(Stuff) if (is(Stuff : bool))
  alias stableReplace;
    Inserts stuff before, after, or instead range r, which must be a valid range previously extracted from this container. stuff can be a value convertible to ElementType or a range of objects convertible to ElementType. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    The number of values inserted.

    Complexity:
    Ο(n + m), where m is the length of stuff

    ulong insertBefore(Range r, Stuff stuff);
      Inserts stuff before, after, or instead range r, which must be a valid range previously extracted from this container. stuff can be a value convertible to ElementType or a range of objects convertible to ElementType. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

      Returns:
      The number of values inserted.

      Complexity:
      Ο(n + m), where m is the length of stuff

  Range linearRemove(Range r);
  alias stableLinearRemove;
    Removes all elements belonging to r, which must be a range obtained originally from this container. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.

    Returns:
    A range spanning the remaining elements in the container that initially were right after r.

    Complexity:
    Ο(n)

Copyright 2010- Andrei Alexandrescu. | Page generated by Ddoc.