Commit ff36eae2 authored by Maciej (Matthew) Piechotka's avatar Maciej (Matthew) Piechotka
Browse files

Add read_only_view to Gee.MultiMap, fixes bug #687158

parent 5fcd51c3
......@@ -56,6 +56,7 @@ libgee_0_8_la_SOURCES = \
readonlycollection.vala \
readonlylist.vala \
readonlymap.vala \
readonlymultimap.vala \
readonlymultiset.vala \
readonlyset.vala \
readonlysortedmap.vala \
......
......@@ -309,6 +309,19 @@ public abstract class Gee.AbstractMultiMap<K,V> : Object, MultiMap<K,V> {
public bool mutable { get { return false; } }
}
private weak MultiMap<K, V> _read_only_view;
public virtual new MultiMap<K, V> read_only_view {
owned get {
MultiMap<K, V> instance = _read_only_view;
if (_read_only_view == null) {
instance = new ReadOnlyMultiMap<K, V> (this);
_read_only_view = instance;
instance.add_weak_pointer ((void**) (&_read_only_view));
}
return instance;
}
}
// Future-proofing
internal new virtual void reserved0() {}
internal new virtual void reserved1() {}
......@@ -319,5 +332,5 @@ public abstract class Gee.AbstractMultiMap<K,V> : Object, MultiMap<K,V> {
internal new virtual void reserved6() {}
internal new virtual void reserved7() {}
internal new virtual void reserved8() {}
internal new virtual void reserved9() {}
}
......@@ -124,4 +124,10 @@ public interface Gee.MultiMap<K,V> : Object {
* The type of the values in this multimap.
*/
public Type value_type { get { return typeof (V); } }
public virtual MultiMap<K, V> read_only_view {
owned get {
return new ReadOnlyMultiMap<K, V> (this);
}
}
}
......@@ -244,7 +244,7 @@ internal class Gee.ReadOnlyMap<K,V> : Object, Traversable<Map.Entry<K,V>>, Itera
return _map.chop (offset, length);
}
protected class MapIterator<K,V> : Object, Gee.MapIterator<K,V> {
internal class MapIterator<K,V> : Object, Gee.MapIterator<K,V> {
protected Gee.MapIterator<K,V> _iter;
public MapIterator (Gee.MapIterator<K,V> iterator) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment