D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Sat Feb 14 12:00:03 2009

# std.iterator

This module is a port of a growing fragment of the algorithm header in Alexander Stepanov's Standard Template Library.
Author:
Andrei Alexandrescu
Note:
For now only iterators for built-in arrays are defined. Built-in arrays are also considered ranges themselves. The iterator of a built-in array T[] is a pointer of type T*. This may change in the future.

template Iterator(Range : T[],T)
  Iterator!(Range) or Iterator!(Collection) is the type that is able to iterate an object of type Range or Collection, respectively. This defines Iterator!(T[]) to be T* for all types T.
template ElementType(Range : T[],T)
  The element type of a range. For a built-in array T[], the element type is T.
bool isEmpty(T)(T[] r);
  Returns true if and only if the range r is empty.
Iterator!(T[]) begin(T)(T[] r);
  Returns an iterator to the beginning of the range r.
Iterator!(T[]) end(T)(T[] r);
  Returns an iterator just past the end of the range r.
ElementType!(T[]) front(T)(T[] r);
  Returns the front element of the range.
  Preconditions:
  !isEmpty(r)
T[] range(T)(T* first, T* last);
  Creates a range from a pair of iterators.
  Precondition:
  last must be reachable from first (for pointers, both must belong to the same memory chunk and last >= first).
struct Retro(R : E[],E);
  Type that reverses the iteration order of a range.
Retro!(E[]) retro(E)(E[] r);
  Returns a range that iterates r backwards.
Iterator!(Retro!(F[])) rBegin(F)(F[] range);
  Returns begin(retro(range)).
Iterator!(Retro!(F[])) rEnd(F)(F[] range);
  Returns end(retro(range)).

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