std.container.slist

This module implements a singly-linked list container. It can be used as a stack.

This module is a submodule of std.container.

Public Imports

std.container.util
public import std.container.util;
Undocumented in source.

Members

Structs

SList
struct SList(T)

Implements a simple and fast singly-linked list. It can be used as a stack.

Examples

import std.algorithm.comparison : equal;
import std.container : SList;

auto s = SList!int(1, 2, 3);
assert(equal(s[], [1, 2, 3]));

s.removeFront();
assert(equal(s[], [2, 3]));

s.insertFront([5, 6]);
assert(equal(s[], [5, 6, 2, 3]));

// If you want to apply range operations, simply slice it.
import std.algorithm.searching : countUntil;
import std.range : popFrontN, walkLength;

auto sl = SList!int(1, 2, 3, 4, 5);
assert(countUntil(sl[], 2) == 1);

auto r = sl[];
popFrontN(r, 2);
assert(walkLength(r) == 3);

Meta

License

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