std.slist - D Programming Language - Digital Mars

D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Tue Nov 27 20:25:03 2007

# std.slist

struct SList(T);
  Singly-linked list. The intent is to make it as efficient as the simplest hand-coded list. Therefore, no tricks are employed - no phantom node, no circularity, no fat iterators, just a straight list of nodes terminated by null. Therefore, SList only supports forward iteration, does not have access to its last element, and only supports adding elements to the front or after the current iterator.
  SList opCall(size_t length, T value);
    Builds a list of length elements, initialized with value.
  SList opCall(size_t length = 0);
    Build a list of length elements, initialized with T.init.
  template opEquals(U)
    Compares a list with an array for element-wise equality.
    int opEquals(const(U)[] v);
      Compares a list with an array for element-wise equality.
Iterator!(SList!(T)) begin(T)(ref SList!(T) lst);
  Returns an iterator to the head of the list.
Iterator!(SList!(T)) end(T)(ref SList!(T) lst);
  Returns an iterator after the end of the list (null in fact).
Ref!(T) front(T)(ref SList!(T) lst);
  Returns the first element in the list. Precondition: !isEmpty(lst).
Iterator!(SList!(T)) pushFront(T,U...)(ref SList!(T) lst, U elems);
  Pushes elems to the front of the list lst, and returns an iterator to the root of the list.
bool isEmpty(T)(ref SList!(T) lst);
  True if and only if lst is empty.
struct Iterator(L : SList!(T),T);
  List iterator. Models forward iteration.
T get(T)(Iterator!(SList!(T)) i);
  Read the value pointed to by the iterator.
T set(T,U)(ref Iterator!(SList!(T)) i, U rhs);
  Assign to the value pointed to by the iterator.
void next(T)(ref Iterator!(SList!(T)) i);
  Increment the iterator.
void popFront(T)(ref SList!(T) lst);
  Pops the element in the front of the list lst.
Iterator!(SList!(T)) insertAfter(T,U)(ref SList!(T) lst, Iterator!(SList!(T)) i, U value);
  Inserts an element with value value in lst after i. Returns an iterator to the element just inserted.
void insertAfter(T,U)(ref SList!(T) lst, Iterator!(SList!(T)) i, Iterator!(U) begin, Iterator!(U) end);
  Pushes a range to the front of the list lst, and returns an iterator to the last element inserted.
void insertAfter(T,U)(ref SList!(T) lst, Iterator!(SList!(T)) i, size_t n, U value);
  Pushes n copies of value to the front of the list lst, and returns an iterator to the last element inserted.
Iterator!(SList!(T)) eraseAfter(T)(ref SList!(T), Iterator!(SList!(T)) i);
  Erases the element after the one pointed to by i.
Iterator!(SList!(T)) eraseAfter(T)(ref SList!(T) lst, Iterator!(SList!(T)) begin, Iterator!(SList!(T)) end);
  Erases the elements from the element after the one pointed to by begin, up to (and including) the one pointed to by end.
void clear(T)(ref SList!(T) lst);
  Erases the elements from the element after the one pointed to by begin, up to (and including) the one pointed to by end.
void resize(T)(ref SList!(T) lst, size_t n);
void resize(T,U)(ref SList!(T) lst, size_t n, U value);
  Inserts or erases elements at the front of lst such that the size becomes n.
size_t distanceLin(T)(Iterator!(T) from, Iterator!(T) to);
  Computes the distance between two iterators in linear or better time.
Iterator!(T) lastLin(T)(Iterator!(T) from, Iterator!(T) to);
  Computes the last valid iterator before to in linear or better time.
bool getNext(It : Iterator!(List!(int)))(It i, ref T target);
  Reads the value pointed to by the iterator, and increments the iterator.

Copyright © 1999-2007 by Digital Mars, All Rights Reserved | Page generated by Ddoc.