public bool valid {
get {
- stderr.printf ("%d %s\n", _index, _removed ? "true" : "false");
return _index >= 0 && _index < _list._size && ! _removed;
}
}
* progress to next element when the operation repeats.
*
* Operation moves the iterator to last element in iteration. If iterator
- * points at some element it will be included in iteration
+ * points at some element it will be included in iteration.
*/
public virtual A fold<A> (FoldFunc<A, G> f, owned A seed)
{
seed = f (get (), (owned) seed);
return (owned) seed;
}
+
+ /**
+ * Apply function to each element returned by iterator.
+ *
+ * Operation moves the iterator to last element in iteration. If iterator
+ * points at some element it will be included in iteration.
+ */
+ public virtual void forall (ForallFunc<G> f) {
+ if (valid)
+ f (get ());
+ while (next ())
+ f (get ());
+ }
}
add_test ("[Collection] retain_all", test_retain_all);
add_test ("[Collection] to_array", test_to_array);
add_test ("[Collection] GObject properties", test_gobject_properties);
- add_test ("[Collection] fold", test_to_array);
+ add_test ("[Collection] fold", test_fold);
}
protected Collection<string> test_collection;