Traversable
Object Hierarchy:
Description:
[ GenericAccessors ]
public interface Traversable<G> : Object
It's a common interface for Iterator and
Iterable. It provides a fast, high level functions.
Iterator implementation: Please note that most of the functions affect the state
of the iterator by moving it forward. Even if the iterator is BidirIterator it
must not rewind the state.
Iterable implementation: validy (
Iterator.valid) of returned iterator is the same as for invalid iterator.
In other words the following code is semantically equivalent:
var x = iterable.function (args);
var x = iterable.iterator ().function(args);
Since:
0.7.0
All known implementing classes:
All known sub-interfaces:
Content:
Enums:
Properties:
Methods:
- public abstract bool @foreach (ForallFunc<G> f)
Apply function to each element returned by iterator until last element
or function return false.
- public virtual bool all_match (owned Predicate<G> pred)
Checks whether all elements match the given predicate.
- public virtual bool any_match (owned Predicate<G> pred)
Returns whether any element matches the given predicate.
- public virtual Iterator<G> chop (int offset, int length = -1)
Creates a new iterator which contains elements from iterable. The
first argument states the offset i.e. number of elements the iterator skips by default.
- public virtual Iterator<G> filter (owned Predicate<G> pred)
Creates a new iterator that contains only values that fulfills the
predicate.
- public virtual G first_match (owned Predicate<G> pred)
Returns the first element that matches a given condition
- public virtual Iterator<A> flat_map<A> (owned FlatMapFunc<A,G> f)
A fused concatenate and map. The function is applied to each element
of iteration and the resulting values are concatenated.
- public virtual A fold<A> (FoldFunc<A,G> f, owned A seed)
Standard aggregation function.
- public virtual Iterator<A> map<A> (MapFunc<A,G> f)
Produces an iterator pointing at elements generated by function
passed.
- public virtual G max (owned CompareDataFunc<G> compare)
Returns the item in the sequence that contains the max value based on
the given compare function.
- public virtual G min (owned CompareDataFunc<G> compare)
Returns the item in the sequence that contains the min value based on
the given compare function.
- public virtual Iterator<G> order_by (owned CompareDataFunc<G>? compare = null)
Returns a new iterator containing the elements in the source ordered
as specified by the comparison function.
- public virtual Iterator<A> scan<A> (FoldFunc<A,G> f, owned A seed)
Creates a new iterator that is initially pointing to seed. Then
subsequent values are obtained after applying the function to previous value and the subsequent items.
- public virtual Iterator<A> stream<A> (owned StreamFunc<G,A> f)
Stream function is an abstract function allowing writing many
operations.
- public virtual Iterator<G>[] tee (uint forks)
Splits the traversable into multiple ones, caching the result if
needed.
Inherited Members:
All known members inherited from class GLib.Object
- @get
- @new
- @ref
- @set
- add_toggle_ref
- add_weak_pointer
- bind_property
- connect
- constructed
- disconnect
- dispose
- dup_data
- dup_qdata
- force_floating
- freeze_notify
- get_class
- get_data
- get_property
- get_qdata
- get_type
- getv
- interface_find_property
- interface_install_property
- interface_list_properties
- is_floating
- new_valist
- new_with_properties
- newv
- notify
- notify_property
- ref_count
- ref_sink
- remove_toggle_ref
- remove_weak_pointer
- replace_data
- replace_qdata
- set_data
- set_data_full
- set_property
- set_qdata
- set_qdata_full
- set_valist
- setv
- steal_data
- steal_qdata
- thaw_notify
- unref
- watch_closure
- weak_ref
- weak_unref