* @see AbstractSet
* @see AbstractMultiSet
*/
-public abstract class Gee.AbstractCollection<G> : Object, Iterable<G>, Collection<G> {
+public abstract class Gee.AbstractCollection<G> : Object, Traversable<G>, Iterable<G>, Collection<G> {
/**
* {@inheritDoc}
*/
public abstract Iterator<G> iterator ();
+ public virtual void foreach (ForallFunc<G> f) {
+ iterator ().foreach (f);
+ }
+
+ public virtual Iterator<A> stream<A> (owned StreamFunc<G, A> f) {
+ return iterator ().stream<A> ((owned) f);
+ }
+
private weak Collection<G> _read_only_view;
/**
* @see HashMap
* @see TreeMap
*/
-public abstract class Gee.AbstractMap<K,V> : Object, Iterable<Map.Entry<K,V>>, Map<K,V> {
+public abstract class Gee.AbstractMap<K,V> : Object, Traversable<Map.Entry<K,V>>, Iterable<Map.Entry<K,V>>, Map<K,V> {
/**
* {@inheritDoc}
public Iterator<Map.Entry<K,V>> iterator () {
return entries.iterator ();
}
+
+ /**
+ * {@inheritDoc}
+ */
+ public virtual void foreach (ForallFunc<Map.Entry<K,V>> f) {
+ iterator ().foreach (f);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public virtual Iterator<A> stream<A> (owned StreamFunc<Map.Entry<K,V>, A> f) {
+ return iterator ().stream<A> ((owned) f);
+ }
}
/**
* An object that can provide an {@link Iterator}.
*/
-public interface Gee.Iterable<G> : Object {
+public interface Gee.Iterable<G> : Object, Traversable<G> {
/**
* The type of the elements in this collection.
*/
*
* @see Collection
*/
-internal class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Collection<G> {
+internal class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Traversable<G>, Collection<G> {
/**
* {@inheritDoc}
/**
* {@inheritDoc}
*/
+ public void foreach (ForallFunc<G> f) {
+ _collection.foreach (f);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Gee.Iterator<A> stream<A> (owned StreamFunc<A> f) {
+ return _collection.stream<A> (f);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public Type element_type {
get { return typeof (G); }
}
*
* @see Map
*/
-internal class Gee.ReadOnlyMap<K,V> : Object, Iterable<Map.Entry<K,V>>, Map<K,V> {
+internal class Gee.ReadOnlyMap<K,V> : Object, Traversable<Map.Entry<K,V>>, Iterable<Map.Entry<K,V>>, Map<K,V> {
/**
* {@inheritDoc}
return entries.iterator ();
}
+ /**
+ * {@inheritDoc}
+ */
+ public void foreach (ForallFunc<Map.Entry<K, V>> f) {
+ _map.foreach (f);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Iterator<A> stream<A> (owned StreamFunc<Map.Entry<K, V>, A> f) {
+ return _map.stream<A> ((owned) f);
+ }
+
protected class MapIterator<K,V> : Object, Gee.MapIterator<K,V> {
protected Gee.MapIterator<K,V> _iter;