SList.removeFront - multiple declarations

Function SList.removeFront

Removes the front element.

void removeFront();

Precondition

!empty

Example

SList!int l;

l.insertFront(8);
l.insertFront(9);
assert(l.front == 9);
l.removeFront();
assert(l.front == 8);
l.removeFront();
assert(l.empty);

Function SList.removeFront

Removes howMany elements from the list.

size_t removeFront (
  size_t howMany
);

Unlike removeFront(), this method doesn't fail, if it could not remove howMany elements. Instead, if howMany is greater than the list length, all elements are removed.

Parameters

NameDescription
howMany How many elements should be removed.

Returns

The number of elements removed.

Example

SList!int l = SList!int([8, 5, 4]);

assert(l.removeFront(0) == 0);
assert(l.removeFront(2) == 2);
assert(l.removeFront(3) == 1);
assert(l.removeFront(3) == 0);