DList.this - multiple declarations

Function DList.this

Creates a new DList with the elements from a static array.

this(size_t R) (
  T[R] init,
  shared Allocator allocator = defaultAllocator
);

Parameters

NameDescription
R Static array size.
init Values to initialize the list with.
allocator Allocator.

Example

auto l = DList!int([5, 8, 15]);
assert(l.front == 5);

Function DList.this

Creates a new DList with the elements from an input range.

this(R) (
  scope R init,
  shared Allocator allocator = defaultAllocator
)
if (!isInfinite!R && isInputRange!R && isImplicitlyConvertible!(ElementType!R, T));

Parameters

NameDescription
R Type of the initial range.
init Values to initialize the list with.
allocator Allocator.

Function DList.this

Creates a new DList.

this (
  size_t len,
  auto ref T init,
  shared Allocator allocator = defaultAllocator
);

this (
  size_t len,
  shared Allocator allocator = defaultAllocator
);

this (
  shared Allocator allocator
);

Parameters

NameDescription
len Initial length of the list.
init Initial value to fill the list with.
allocator Allocator.

Example

auto l = DList!int(2, 3);
assert(l.front == 3);
assert(l.back == 3);

Example

auto l = DList!int(2);
assert(l.front == 0);

Function DList.this

Initializes this list from another one.

this(R) (
  ref R init,
  shared Allocator allocator = defaultAllocator
)
if (is(Unqual!R == DList));

this(R) (
  R init,
  shared Allocator allocator = defaultAllocator
) @trusted
if (is(R == DList));

If init is passed by value, it won't be copied, but moved. If the allocator of ($D_PARAM init) matches allocator, this will just take the ownership over init's storage, otherwise, the storage will be allocated with allocator and all elements will be moved; init will be destroyed at the end.

If init is passed by reference, it will be copied.

Parameters

NameDescription
R Source list type.
init Source list.
allocator Allocator.

Example

auto l1 = DList!int([5, 1, 234]);
auto l2 = DList!int(l1);
assert(l1 == l2);