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;

Members

Structs

SList
struct SList(T)

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

Examples

1 import std.algorithm.comparison : equal;
2 import std.container : SList;
3 
4 auto s = SList!int(1, 2, 3);
5 assert(equal(s[], [1, 2, 3]));
6 
7 s.removeFront();
8 assert(equal(s[], [2, 3]));
9 
10 s.insertFront([5, 6]);
11 assert(equal(s[], [5, 6, 2, 3]));
12 
13 // If you want to apply range operations, simply slice it.
14 import std.algorithm.searching : countUntil;
15 import std.range : popFrontN, walkLength;
16 
17 auto sl = SList!int(1, 2, 3, 4, 5);
18 assert(countUntil(sl[], 2) == 1);
19 
20 auto r = sl[];
21 popFrontN(r, 2);
22 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 ).

Suggestion Box / Bug Report