SList

Singly-linked list.

Constructors

this
this(T[R] init, Allocator allocator)

Creates a new $(D_PSYMBOL SList) with the elements from a static array.

this
this(R init, Allocator allocator)

Creates a new $(D_PSYMBOL SList) with the elements from an input range.

this
this(size_t len, T init, Allocator allocator)
this(size_t len, Allocator allocator)
this(Allocator allocator)

Creates a new $(D_PSYMBOL SList).

this
this(R init, Allocator allocator)

Initializes this list from another one.

Destructor

~this
~this()

Removes all elements from the list.

Postblit

this(this)
this(this)
Undocumented in source.

Members

Aliases

ConstRange
alias ConstRange = SRange!(const SList)

The range types for $(D_PSYMBOL SList).

Range
alias Range = SRange!SList

The range types for $(D_PSYMBOL SList).

insert
alias insert = insertFront

Inserts a new element at the beginning.

Functions

clear
void clear()

Removes all contents from the list.

insertBefore
size_t insertBefore(Range r, R el)
size_t insertBefore(Range r, T el)

Inserts new elements before r.

insertBefore
size_t insertBefore(Range r, T[R] el)

Inserts elements from a static array before r.

insertFront
size_t insertFront(R el)
size_t insertFront(T[R] el)

Inserts a new element at the beginning.

opAssign
typeof(this) opAssign(R that)

Assigns another list.

opAssign
typeof(this) opAssign(R that)

Assigns an input range.

opAssign
typeof(this) opAssign(T[R] that)

Assigns a static array.

opEquals
bool opEquals(typeof(this) that)

Comparison for equality.

opIndex
Range opIndex()
ConstRange opIndex()
popFirstOf
Range popFirstOf(Range range)

Removes the front element of the range from the list.

remove
Range remove(Range r)

Removes r from the list.

removeFront
void removeFront()

Removes the front element.

removeFront
size_t removeFront(size_t howMany)

Removes howMany elements from the list.

Mixins

__anonymous
mixin DefaultAllocator
Undocumented in source.

Properties

empty
bool empty [@property getter]
front
inout(T) front [@property getter]

Mixed In Members

From mixin DefaultAllocator

allocator_
Allocator allocator_;

Allocator.

this
this(Allocator allocator)
allocator
shared(Allocator) allocator [@property getter]

This property checks if the allocator was set in the constructor and sets it to the default one, if not.

Parameters

T

Content type.

Examples

SList!int l;
size_t i;

l.insertFront(5);
l.insertFront(4);
l.insertFront(9);
foreach (e; l)
{
    assert(i != 0 || e == 9);
    assert(i != 1 || e == 4);
    assert(i != 2 || e == 5);
    ++i;
}
assert(i == 3);

Meta