Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
std.container.dlist
This module implements a generic doubly-linked list container.
It can be used as a queue, dequeue or stack.
This module is a submodule of std.container.
Source: std/container/dlist.d
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:
Steven Schveighoffer, Andrei Alexandrescu
Examples:
import std.container: DList; import std.algorithm: equal; auto s = DList!int(1, 2, 3); assert(equal(s[], [1, 2, 3])); s.removeFront(); assert(equal(s[], [2, 3])); s.removeBack(); assert(equal(s[], [2])); s.insertFront([4, 5]); assert(equal(s[], [4, 5, 2])); s.insertBack([6, 7]); assert(equal(s[], [4, 5, 2, 6, 7])); // If you want to apply range operations, simply slice it. import std.algorithm: countUntil; import std.range: popFrontN, popBackN, walkLength; auto sl = DList!int([1, 2, 3, 4, 5]); assert(countUntil(sl[], 2) == 1); auto r = sl[]; popFrontN(r, 2); popBackN(r, 2); assert(r.equal([3])); assert(walkLength(r) == 1);
- Implements a doubly-linked list.
- Constructor taking a number of nodes
- Constructor taking an input range
- Comparison for equality.
Complexity: Ο(min(n, n1)) where n1 is the number of elements in rhs.
- Defines the container's primary range, which embodies a bidirectional range.
- Property returning true if and only if the container has no elements.
Complexity: Ο(1)
- Removes all contents from the DList.
Postcondition: empty
Complexity: Ο(1)
- Duplicates the container. The elements themselves are not transitively duplicated.
Complexity: Ο(n).
- Returns a range that iterates over all elements of the container, in forward order.
Complexity: Ο(1)
-
Complexity: Ο(1)
-
Complexity: Ο(1)
- Returns a new DList that's the concatenation of this and its argument rhs.
- Returns a new DList that's the concatenation of the argument lhs and this.
- Appends the contents of the argument rhs into this.
- Inserts stuff to the front/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: Ο(log(n))
- Inserts stuff after range r, which must be a non-empty 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: Ο(k + m), where k is the number of elements in r and m is the length of stuff.
- Picks one value in an unspecified position 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: Ο(1).
- Removes the value at the front/back of the container. The stable version behaves the same, but guarantees that ranges iterating over the container are never invalidated.
Precondition: !empty
Complexity: Ο(1).
- 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).
- Removes all elements belonging to r, which must be a range obtained originally from this container.Returns:A range spanning the remaining elements in the container that initially were right after r.
Complexity: Ο(1)
- linearRemove functions as remove, but also accepts ranges that are result the of a take operation. This is a convenient way to remove a fixed amount of elements from the range.
Complexity: Ο(r.walkLength)
Red-black tree code copyright (C) 2008- by Steven Schveighoffer. Other code
copyright 2010- Andrei Alexandrescu. All rights reserved by the respective holders.
| Page generated by
Ddoc on (no date time)