License:
see license.txt
This is a collection of useful iterators, and iterator
functions.
- class
TransformIterator
(V,U = V): Iterator!(V);
- This iterator transforms every element from another iterator using a
transformation function.
- this(Iterator!(U) source, void delegate(ref U, ref V) dg);
- Construct a transform iterator using a transform delegate.
The transform function transforms a type U object into a type V object.
- this(Iterator!(U) source, void(* fn)(ref U, ref V));
- Construct a transform iterator using a transform function pointer.
The transform function transforms a type U object into a type V object.
- uint
length
();
- Returns the
length
that the source provides.
- int
opApply
(int delegate(ref V v) dg);
- Iterate through the source iterator, working with temporary copies of a
transformed V element.
- class
TransformKeyedIterator
(K,V,J = K,U = V): KeyedIterator!(K,V);
- Transform for a keyed iterator
- this(KeyedIterator!(J,U) source, void delegate(ref J, ref U, ref K, ref V) dg);
- Construct a transform iterator using a transform delegate.
The transform function transforms a J, U pair into a K, V pair.
- this(KeyedIterator!(J,U) source, void(* fn)(ref J, ref U, ref K, ref V));
- Construct a transform iterator using a transform function pointer.
The transform function transforms a J, U pair into a K, V pair.
- uint
length
();
- Returns the
length
that the source provides.
- int
opApply
(int delegate(ref V v) dg);
- Iterate through the source iterator, working with temporary copies of a
transformed V element. Note that K can be ignored if this is the only
use for the iterator.
- int
opApply
(int delegate(ref K k, ref V v) dg);
- Iterate through the source iterator, working with temporary copies of a
transformed K,V pair.
- class
ChainIterator
(V): Iterator!(V);
- A Chain iterator chains several iterators together.
- this(Iterator!(V)[] chain...);
- Constructor. Pass in the iterators you wish to chain together in the
order you wish them to be chained.
If all of the iterators support length, then this iterator supports
length. If one doesn't, then the length is not supported.
- uint
length
();
- Returns the sum of all the iterator lengths in the chain.
returns NO_LENGTH_SUPPORT if a single iterator in the chain does not support
length
- int
opApply
(int delegate(ref V v) dg);
- Iterate through the chain of iterators.
- class
ChainKeyedIterator
(K,V): KeyedIterator!(K,V);
- A Chain iterator chains several iterators together.
- this(KeyedIterator!(K,V)[] chain...);
- Constructor. Pass in the iterators you wish to chain together in the
order you wish them to be chained.
If all of the iterators support length, then this iterator supports
length. If one doesn't, then the length is not supported.
- uint
length
();
- Returns the sum of all the iterator lengths in the chain.
returns NO_LENGTH_SUPPORT if any iterators in the chain return -1 for
length
- int
opApply
(int delegate(ref V v) dg);
- Iterate through the chain of iterators using values only.
- int
opApply
(int delegate(ref K, ref V) dg);
- Iterate through the chain of iterators using keys and values.
- class
FilterIterator
(V): Iterator!(V);
- A Filter iterator filters out unwanted elements based on a function or
delegate.
- this(Iterator!(V) source, bool delegate(ref V) dg);
- Construct a filter iterator with the given delegate deciding whether an
element will be iterated or not.
The delegate should return true for elements that should be iterated.
- this(Iterator!(V) source, bool(* fn)(ref V));
- Construct a filter iterator with the given function deciding whether an
element will be iterated or not.
the function should return true for elements that should be iterated.
- uint
length
();
- Returns NO_LENGTH_SUPPORT
- int
opApply
(int delegate(ref V v) dg);
- Iterate through the source iterator, only accepting elements where the
delegate/function returns true.
- class
FilterKeyedIterator
(K,V): KeyedIterator!(K,V);
- A Filter iterator filters out unwanted elements based on a function or
delegate. This version filters on a keyed iterator.
- this(KeyedIterator!(K,V) source, bool delegate(ref K, ref V) dg);
- Construct a filter iterator with the given delegate deciding whether a
key/value pair will be iterated or not.
The delegate should return true for elements that should be iterated.
- this(KeyedIterator!(K,V) source, bool(* fn)(ref K, ref V));
- Construct a filter iterator with the given function deciding whether a
key/value pair will be iterated or not.
the function should return true for elements that should be iterated.
- uint
length
();
- Returns NO_LENGTH_SUPPORT
- int
opApply
(int delegate(ref V v) dg);
- Iterate through the source iterator, only iterating elements where the
delegate/function returns true.
- int
opApply
(int delegate(ref K k, ref V v) dg);
- Iterate through the source iterator, only iterating elements where the
delegate/function returns true.
- class
ArrayIterator
(V): Iterator!(V);
- Simple iterator wrapper for an array.
- this(V[] array);
- Wrap a given array. Note that this does not make a copy.
- uint
length
();
- Returns the array
length
- int
opApply
(int delegate(ref V) dg);
- Iterate over the array.
- class
AAIterator
(K,V): KeyedIterator!(K,V);
- Wrapper iterator for an associative array
- this(V[K] array);
- Construct an iterator wrapper for the given array
- uint
length
();
- Returns the
length
of the wrapped AA
- int
opApply
(int delegate(ref K, ref V) dg);
- Iterate over the AA
- V[]
toArray
(V)(Iterator!(V) it);
- Function that converts an iterator to an array.
More optimized for iterators that support a length.
- V[K]
toAA
(K,V)(KeyedIterator!(K,V) it);
- Convert a keyed iterator to an associative array.
|