[libgee] Make Map<K,V> be an Iterable<Map.Entry<K,V>>
- From: Didier Villevalois <dvillevalois src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgee] Make Map<K,V> be an Iterable<Map.Entry<K,V>>
- Date: Wed, 23 Sep 2009 21:58:38 +0000 (UTC)
commit 027c95c580ba209cc8c0a9ebe1c61e0dd0adc61d
Author: Didier 'Ptitjes <ptitjes free fr>
Date: Wed Sep 23 23:57:42 2009 +0200
Make Map<K,V> be an Iterable<Map.Entry<K,V>>
gee/abstractmap.vala | 15 ++++++++++++++-
gee/map.vala | 2 +-
gee/readonlymap.vala | 16 +++++++++++++++-
3 files changed, 30 insertions(+), 3 deletions(-)
---
diff --git a/gee/abstractmap.vala b/gee/abstractmap.vala
index a68ceda..e798876 100644
--- a/gee/abstractmap.vala
+++ b/gee/abstractmap.vala
@@ -30,7 +30,7 @@
* @see Gee.TreeMap
* @see Gee.HashMap
*/
-public abstract class Gee.AbstractMap<K,V> : Object, Map<K,V> {
+public abstract class Gee.AbstractMap<K,V> : Object, Iterable<Map.Entry<K,V>>, Map<K,V> {
/**
* @inheritDoc
@@ -176,4 +176,17 @@ public abstract class Gee.AbstractMap<K,V> : Object, Map<K,V> {
}
}
+ /**
+ * @inheritDoc
+ */
+ public Type element_type {
+ get { return typeof (Map.Entry<K,V>); }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Iterator<Map.Entry<K,V>> iterator () {
+ return entries.iterator ();
+ }
}
diff --git a/gee/map.vala b/gee/map.vala
index bdcbd53..c3b244a 100644
--- a/gee/map.vala
+++ b/gee/map.vala
@@ -23,7 +23,7 @@
/**
* An object that maps keys to values.
*/
-public interface Gee.Map<K,V> : GLib.Object {
+public interface Gee.Map<K,V> : GLib.Object, Iterable<Map.Entry<K,V>> {
/**
* The number of items in this map.
*/
diff --git a/gee/readonlymap.vala b/gee/readonlymap.vala
index 6241853..d89ba1e 100644
--- a/gee/readonlymap.vala
+++ b/gee/readonlymap.vala
@@ -31,7 +31,7 @@ using GLib;
*
* @see Gee.Map
*/
-internal class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
+internal class Gee.ReadOnlyMap<K,V> : Object, Iterable<Map.Entry<K,V>>, Map<K,V> {
/**
* @inheritDoc
@@ -187,6 +187,20 @@ internal class Gee.ReadOnlyMap<K,V> : Object, Map<K,V> {
owned get { return this; }
}
+ /**
+ * @inheritDoc
+ */
+ public Type element_type {
+ get { return typeof (Map.Entry<K,V>); }
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Iterator<Map.Entry<K,V>> iterator () {
+ return entries.iterator ();
+ }
+
protected class MapIterator<K,V> : Object, Gee.MapIterator<K,V> {
protected Gee.MapIterator<K,V> _iter;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]