3 * Copyright (C) 2009 Ali Sabil
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * Ali Sabil <ali.sabil@gmail.com>
24 * A map with multiple values per key.
27 public interface Gee.MultiMap<K,V> : Object {
29 * The number of key/value pairs in this map.
31 public abstract int size { get; }
34 * Specifies whether this collection can change - i.e. wheather {@link set},
35 * {@link remove} etc. are legal operations.
37 public abstract bool read_only { get; }
40 * Returns the keys of this multimap as a read-only set.
42 * @return the keys of the map
44 public abstract Set<K> get_keys ();
47 * Returns the keys of this multimap as a read-only set.
49 * @return the keys of the map
51 public abstract MultiSet<K> get_all_keys ();
54 * Returns the values of this map as a read-only collection.
56 * @return the values of the map
58 public abstract Collection<V> get_values ();
61 * Determines whether this map contains the specified key.
63 * @param key the key to locate in the map
65 * @return ``true`` if key is found, ``false`` otherwise
67 public abstract bool contains (K key);
70 * Returns the values for the specified key in this map.
72 * @param key the key whose values are to be retrieved
74 * @return a Collection of values associated with the given key
76 public abstract Collection<V> get (K key);
79 * Inserts a key/value pair into this map.
81 * @param key the key to insert
82 * @param value the value to associate with the key
84 public abstract void set (K key, V value);
87 * Removes the specified key/value pair from this multimap.
89 * @param key the key to remove from the map
90 * @param value the value to remove from the map
92 * @return ``true`` if the map has been changed, ``false`` otherwise
94 public abstract bool remove (K key, V value);
97 * Removes the specified key and all the associated values from this
100 * @param key the key to remove from the map
102 * @return ``true`` if the map has been changed, ``false`` otherwise
104 public abstract bool remove_all (K key);
107 * Removes all items from this collection.
109 public abstract void clear ();
112 * Returns an iterator for this map.
114 * @return a map iterator
116 public abstract MapIterator<K, V> map_iterator ();
119 * The type of the keys in this multimap.
121 public Type key_type { get { return typeof (K); } }
124 * The type of the values in this multimap.
126 public Type value_type { get { return typeof (V); } }
128 public virtual MultiMap<K, V> read_only_view {
130 return new ReadOnlyMultiMap<K, V> (this);