D Programming Language 2.0

- Comments
- D
- Search
- Home

Last update Thu Jan 28 19:18:06 2010

# std.iterator

This module is a port of a growing fragment of the algorithm header in Alexander Stepanov's Standard Template Library.

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.

License:
Boost License 1.0.

Authors:
Andrei Alexandrescu

Copyright Andrei Alexandrescu 2008 - 2009. Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at ) http:
//www.boost.org/LICENSE_1_0.txt

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 Andrei Alexandrescu 2008 - 2009. | Page generated by Ddoc.