[libgee] Add read_only method to Collection, Map and MultiMap



commit 4df3e3a76a3158995e1f37a3c6984ff9aac00f13
Author: Maciej Piechotka <uzytkownik2 gmail com>
Date:   Tue Jan 4 15:46:13 2011 +0100

    Add read_only method to Collection, Map and MultiMap

 gee/abstractcollection.vala |    5 +++++
 gee/abstractmap.vala        |    5 +++++
 gee/abstractmultimap.vala   |    4 ++++
 gee/abstractmultiset.vala   |    4 ++++
 gee/arraylist.vala          |    7 +++++++
 gee/collection.vala         |    6 ++++++
 gee/hashmap.vala            |   19 +++++++++++++++++++
 gee/hashset.vala            |    7 +++++++
 gee/linkedlist.vala         |    7 +++++++
 gee/map.vala                |    6 ++++++
 gee/multimap.vala           |    6 ++++++
 gee/priorityqueue.vala      |    7 +++++++
 gee/readonlycollection.vala |    7 +++++++
 gee/readonlymap.vala        |    7 +++++++
 gee/treemap.vala            |   16 ++++++++++++++++
 gee/treeset.vala            |   11 +++++++++++
 16 files changed, 124 insertions(+), 0 deletions(-)
---
diff --git a/gee/abstractcollection.vala b/gee/abstractcollection.vala
index e7ef6be..8800ba4 100644
--- a/gee/abstractcollection.vala
+++ b/gee/abstractcollection.vala
@@ -47,6 +47,11 @@ public abstract class Gee.AbstractCollection<G> : Object, Iterable<G>, Collectio
 	/**
 	 * { inheritDoc}
 	 */
+	public abstract bool read_only { get; }
+
+	/**
+	 * { inheritDoc}
+	 */
 	public abstract bool contains (G item);
 
 	/**
diff --git a/gee/abstractmap.vala b/gee/abstractmap.vala
index 191a823..df1acdb 100644
--- a/gee/abstractmap.vala
+++ b/gee/abstractmap.vala
@@ -42,6 +42,11 @@ public abstract class Gee.AbstractMap<K,V> : Object, Iterable<Map.Entry<K,V>>, M
 	public virtual bool is_empty {
 		get { return size == 0; }
 	}
+	
+	/**
+	 * { inheritDoc}
+	 */
+	public abstract bool read_only { get; }
 
 	/**
 	 * { inheritDoc}
diff --git a/gee/abstractmultimap.vala b/gee/abstractmultimap.vala
index a7de1cc..ed547eb 100644
--- a/gee/abstractmultimap.vala
+++ b/gee/abstractmultimap.vala
@@ -31,6 +31,10 @@ public abstract class Gee.AbstractMultiMap<K,V> : Object, MultiMap<K,V> {
 	public int size {
 		get { return _nitems; }
 	}
+	
+	public bool read_only {
+		get { return false; }
+	}
 
 	protected Map<K, Collection<V>> _storage_map;
 	private int _nitems = 0;
diff --git a/gee/abstractmultiset.vala b/gee/abstractmultiset.vala
index 307edd4..6b4955e 100644
--- a/gee/abstractmultiset.vala
+++ b/gee/abstractmultiset.vala
@@ -32,6 +32,10 @@ public abstract class Gee.AbstractMultiSet<G> : AbstractCollection<G>, MultiSet<
 		get { return _nitems; }
 	}
 
+	public override bool read_only {
+		get { return false; }
+	}
+
 	protected Map<G, int> _storage_map;
 	private int _nitems = 0;
 
diff --git a/gee/arraylist.vala b/gee/arraylist.vala
index fe61418..44e4fe4 100644
--- a/gee/arraylist.vala
+++ b/gee/arraylist.vala
@@ -44,6 +44,13 @@ public class Gee.ArrayList<G> : AbstractList<G> {
 	public override int size {
 		get { return _size; }
 	}
+	
+	/**
+	 * { inheritDoc}
+	 */
+	public override bool read_only {
+		get { return false; }
+	}
 
 	/**
 	 * The elements' equality testing function.
diff --git a/gee/collection.vala b/gee/collection.vala
index cf988c7..5db67fb 100644
--- a/gee/collection.vala
+++ b/gee/collection.vala
@@ -33,6 +33,12 @@ public interface Gee.Collection<G> : Iterable<G> {
 	 * Specifies whether this collection is empty.
 	 */
 	public abstract bool is_empty { get; }
+	
+	/**
+	 * Specifies whether this collection can change - i.e. wheather { link add},
+	 * { link remove} etc. are legal operations.
+	 */
+	public abstract bool read_only { get; }
 
 	/**
 	 * Determines whether this collection contains the specified item.
diff --git a/gee/hashmap.vala b/gee/hashmap.vala
index ad2599c..cf258c4 100644
--- a/gee/hashmap.vala
+++ b/gee/hashmap.vala
@@ -40,6 +40,13 @@ public class Gee.HashMap<K,V> : Gee.AbstractMap<K,V> {
 	public override int size {
 		get { return _nnodes; }
 	}
+	
+	/**
+	 * { inheritDoc}
+	 */
+	public override bool read_only {
+		get { return false; }
+	}
 
 	/**
 	 * { inheritDoc}
@@ -329,6 +336,10 @@ public class Gee.HashMap<K,V> : Gee.AbstractMap<K,V> {
 			get { return _map.size; }
 		}
 
+		public override bool read_only {
+			get { return true; }
+		}
+
 		public override bool add (K key) {
 			assert_not_reached ();
 		}
@@ -374,6 +385,10 @@ public class Gee.HashMap<K,V> : Gee.AbstractMap<K,V> {
 			get { return _map.size; }
 		}
 
+		public override bool read_only {
+			get { return true; }
+		}
+
 		public override bool add (V value) {
 			assert_not_reached ();
 		}
@@ -424,6 +439,10 @@ public class Gee.HashMap<K,V> : Gee.AbstractMap<K,V> {
 			get { return _map.size; }
 		}
 
+		public override bool read_only {
+			get { return true; }
+		}
+
 		public override bool add (Map.Entry<K, V> entry) {
 			assert_not_reached ();
 		}
diff --git a/gee/hashset.vala b/gee/hashset.vala
index d8c1807..94bea79 100644
--- a/gee/hashset.vala
+++ b/gee/hashset.vala
@@ -45,6 +45,13 @@ public class Gee.HashSet<G> : AbstractSet<G> {
 	public override int size {
 		get { return _nnodes; }
 	}
+	
+	/**
+	 * { inheritDoc}
+	 */
+	public override bool read_only {
+		get { return false; }
+	}
 
 	/**
 	 * The elements' hash function.
diff --git a/gee/linkedlist.vala b/gee/linkedlist.vala
index 28a7f14..cc64f0b 100644
--- a/gee/linkedlist.vala
+++ b/gee/linkedlist.vala
@@ -83,6 +83,13 @@ public class Gee.LinkedList<G> : AbstractList<G>, Queue<G>, Deque<G> {
 	public override int size {
 		get { return this._size; }
 	}
+	
+	/**
+	 * { inheritDoc}
+	 */
+	public override bool read_only {
+		get { return false; }
+	}
 
 	/**
 	 * { inheritDoc}
diff --git a/gee/map.vala b/gee/map.vala
index 20c9aa2..e78bdc7 100644
--- a/gee/map.vala
+++ b/gee/map.vala
@@ -33,6 +33,12 @@ public interface Gee.Map<K,V> : Object, Iterable<Map.Entry<K,V>> {
 	 * Specifies whether this map is empty.
 	 */
 	public abstract bool is_empty { get; }
+	
+	/**
+	 * Specifies whether this collection can change - i.e. wheather { link add},
+	 * { link remove} etc. are legal operations.
+	 */
+	public abstract bool read_only { get; }
 
 	/**
 	 * The read-only view of the keys of this map.
diff --git a/gee/multimap.vala b/gee/multimap.vala
index d358646..71e1c2a 100644
--- a/gee/multimap.vala
+++ b/gee/multimap.vala
@@ -28,6 +28,12 @@ public interface Gee.MultiMap<K,V> : Object {
 	 * The number of key/value pairs in this map.
 	 */
 	public abstract int size { get; }
+	
+	/**
+	 * Specifies whether this collection can change - i.e. wheather { link add},
+	 * { link remove} etc. are legal operations.
+	 */
+	public abstract bool read_only { get; }
 
 	/**
 	 * Returns the keys of this multimap as a read-only set.
diff --git a/gee/priorityqueue.vala b/gee/priorityqueue.vala
index f6e5897..fd45aac 100644
--- a/gee/priorityqueue.vala
+++ b/gee/priorityqueue.vala
@@ -95,6 +95,13 @@ public class Gee.PriorityQueue<G> : Gee.AbstractQueue<G> {
 	public override bool is_full {
 		get { return false; }
 	}
+	
+	/**
+	 * { inheritDoc}
+	 */
+	public override bool read_only {
+		get { return false; }
+	}
 
 	/**
 	 * { inheritDoc}
diff --git a/gee/readonlycollection.vala b/gee/readonlycollection.vala
index 4cf8956..2e7123e 100644
--- a/gee/readonlycollection.vala
+++ b/gee/readonlycollection.vala
@@ -46,6 +46,13 @@ internal class Gee.ReadOnlyCollection<G> : Object, Iterable<G>, Collection<G> {
 	public bool is_empty {
 		get { return _collection.is_empty; }
 	}
+	
+	/**
+	 * { inheritDoc}
+	 */
+	public bool read_only {
+		get { return true; }
+	}
 
 	protected Collection<G> _collection;
 
diff --git a/gee/readonlymap.vala b/gee/readonlymap.vala
index 5b0a160..e01e2ff 100644
--- a/gee/readonlymap.vala
+++ b/gee/readonlymap.vala
@@ -50,6 +50,13 @@ internal class Gee.ReadOnlyMap<K,V> : Object, Iterable<Map.Entry<K,V>>, Map<K,V>
 	/**
 	 * { inheritDoc}
 	 */
+	public bool read_only {
+		get { return true; }
+	}
+
+	/**
+	 * { inheritDoc}
+	 */
 	public Set<K> keys {
 		owned get {
 			return _map.keys;
diff --git a/gee/treemap.vala b/gee/treemap.vala
index 5cf56dc..15c5c52 100644
--- a/gee/treemap.vala
+++ b/gee/treemap.vala
@@ -38,6 +38,10 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
 	public override int size {
 		get { return _size; }
 	}
+	
+	public override bool read_only {
+		get { return false; }
+	}
 
 	/**
 	 * { inheritDoc}
@@ -479,6 +483,10 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
 			get { return _map.size; }
 		}
 
+		public override bool read_only {
+			get { return true; }
+		}
+
 		public override bool add (K key) {
 			assert_not_reached ();
 		}
@@ -523,6 +531,10 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
 			get { return _map.size; }
 		}
 
+		public override bool read_only {
+			get { return true; }
+		}
+
 		public override bool add (V key) {
 			assert_not_reached ();
 		}
@@ -573,6 +585,10 @@ public class Gee.TreeMap<K,V> : Gee.AbstractMap<K,V> {
 			get { return _map.size; }
 		}
 
+		public override bool read_only {
+			get { return true; }
+		}
+
 		public override bool add (Map.Entry<K, V> entry) {
 			assert_not_reached ();
 		}
diff --git a/gee/treeset.vala b/gee/treeset.vala
index 2dea5e9..58669c5 100644
--- a/gee/treeset.vala
+++ b/gee/treeset.vala
@@ -39,6 +39,13 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
 	public override int size {
 		get {return _size;}
 	}
+	
+	/**
+	 * { inheritDoc}
+	 */
+	public override bool read_only {
+		get { return false; }
+	}
 
 	/**
 	 * The elements' comparator function.
@@ -897,6 +904,10 @@ public class Gee.TreeSet<G> : AbstractSet<G>, SortedSet<G> {
 			}
 		}
 
+		public override bool read_only {
+			get { return true; }
+		}
+
 		public override bool is_empty {
 			get {
 				return range.empty_subset ();



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]