[libgee] Introduce immutable empty collection, list, set and map
- From: Didier Villevalois <dvillevalois src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgee] Introduce immutable empty collection, list, set and map
- Date: Wed, 23 Sep 2009 22:43:47 +0000 (UTC)
commit 9968b87f3bd6f0521dc046683448e50ffa7bb87a
Author: Didier 'Ptitjes <ptitjes free fr>
Date: Thu Sep 24 00:41:14 2009 +0200
Introduce immutable empty collection, list, set and map
gee/collection.vala | 9 +++++++++
gee/list.vala | 9 +++++++++
gee/map.vala | 9 +++++++++
gee/set.vala | 8 ++++++++
4 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/gee/collection.vala b/gee/collection.vala
index d70da7a..32dd0ad 100644
--- a/gee/collection.vala
+++ b/gee/collection.vala
@@ -126,5 +126,14 @@ public interface Gee.Collection<G> : Iterable<G> {
* Property giving access to the read-only view of this collection.
*/
public abstract Collection<G> read_only_view { owned get; }
+
+ /**
+ * Returns an immutable empty collection.
+ *
+ * @return an immutable empty collection
+ */
+ public static Collection<G> empty<G> () {
+ return new HashSet<G> ().read_only_view;
+ }
}
diff --git a/gee/list.vala b/gee/list.vala
index eae18b1..c6e74e1 100644
--- a/gee/list.vala
+++ b/gee/list.vala
@@ -117,5 +117,14 @@ public interface Gee.List<G> : Collection<G> {
* Property giving access to the read-only view of this list.
*/
public abstract new List<G> read_only_view { owned get; }
+
+ /**
+ * Returns an immutable empty list.
+ *
+ * @return an immutable empty list
+ */
+ public static List<G> empty<G> () {
+ return new LinkedList<G> ().read_only_view;
+ }
}
diff --git a/gee/map.vala b/gee/map.vala
index c3b244a..f085c5f 100644
--- a/gee/map.vala
+++ b/gee/map.vala
@@ -188,5 +188,14 @@ public interface Gee.Map<K,V> : GLib.Object, Iterable<Map.Entry<K,V>> {
* Property giving access to the read-only view this map.
*/
public abstract Map<K,V> read_only_view { owned get; }
+
+ /**
+ * Returns an immutable empty map.
+ *
+ * @return an immutable empty map
+ */
+ public static Map<K,V> empty<K,V> () {
+ return new HashMap<K,V> ().read_only_view;
+ }
}
diff --git a/gee/set.vala b/gee/set.vala
index 15e8ff6..019d906 100644
--- a/gee/set.vala
+++ b/gee/set.vala
@@ -30,5 +30,13 @@ public interface Gee.Set<G> : Collection<G> {
*/
public abstract new Set<G> read_only_view { owned get; }
+ /**
+ * Returns an immutable empty set.
+ *
+ * @return an immutable empty set
+ */
+ public static Set<G> empty<G> () {
+ return new HashSet<G> ().read_only_view;
+ }
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]