3 * Copyright (C) 2007 Jürg Billeter
4 * Copyright (C) 2009 Didier Villevalois
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 * Tomaž Vajngerl <quikee@gmail.com>
25 * Skeletal implementation of the {@link Map} interface.
27 * Contains common code shared by all map implementations.
32 public abstract class Gee.AbstractMap<K,V> : Object, Traversable<Map.Entry<K,V>>, Iterable<Map.Entry<K,V>>, Map<K,V> {
37 public abstract int size { get; }
42 public abstract bool read_only { get; }
47 public abstract Set<K> keys { owned get; }
52 public abstract Collection<V> values { owned get; }
57 public abstract Set<Map.Entry<K,V>> entries { owned get; }
62 public abstract bool has_key (K key);
67 public abstract bool has (K key, V value);
72 public abstract new V? get (K key);
77 public abstract new void set (K key, V value);
82 public abstract bool unset (K key, out V? value = null);
87 public abstract MapIterator<K,V> map_iterator ();
92 public abstract void clear ();
94 private weak Map<K,V> _read_only_view;
99 public virtual Map<K,V> read_only_view {
101 Map<K,V> instance = _read_only_view;
102 if (_read_only_view == null) {
103 instance = new ReadOnlyMap<K,V> (this);
104 _read_only_view = instance;
105 instance.add_weak_pointer ((void**) (&_read_only_view));
114 public Iterator<Map.Entry<K,V>> iterator () {
115 return entries.iterator ();
121 public virtual void foreach (ForallFunc<Map.Entry<K,V>> f) {
122 iterator ().foreach (f);
128 public virtual Iterator<A> stream<A> (owned StreamFunc<Map.Entry<K,V>, A> f) {
129 return iterator ().stream<A> ((owned) f);
133 internal new virtual void reserved0() {}
134 internal new virtual void reserved1() {}
135 internal new virtual void reserved2() {}
136 internal new virtual void reserved3() {}
137 internal new virtual void reserved4() {}
138 internal new virtual void reserved5() {}
139 internal new virtual void reserved6() {}
140 internal new virtual void reserved7() {}
141 internal new virtual void reserved8() {}
142 internal new virtual void reserved9() {}