Update Changelog
[profile/ivi/libgee.git] / gee / multimap.vala
1 /* multimap.vala
2  *
3  * Copyright (C) 2009  Ali Sabil
4  *
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.
9
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.
14
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
18  *
19  * Author:
20  *      Ali Sabil <ali.sabil@gmail.com>
21  */
22
23 /**
24  * A map with multiple values per key.
25  */
26 [GenericAccessors]
27 public interface Gee.MultiMap<K,V> : Object {
28         /**
29          * The number of key/value pairs in this map.
30          */
31         public abstract int size { get; }
32         
33         /**
34          * Specifies whether this collection can change - i.e. wheather {@link set},
35          * {@link remove} etc. are legal operations.
36          */
37         public abstract bool read_only { get; }
38
39         /**
40          * Returns the keys of this multimap as a read-only set.
41          *
42          * @return the keys of the map
43          */
44         public abstract Set<K> get_keys ();
45
46         /**
47          * Returns the keys of this multimap as a read-only set.
48          *
49          * @return the keys of the map
50          */
51         public abstract MultiSet<K> get_all_keys ();
52
53         /**
54          * Returns the values of this map as a read-only collection.
55          *
56          * @return the values of the map
57          */
58         public abstract Collection<V> get_values ();
59
60         /**
61          * Determines whether this map contains the specified key.
62          *
63          * @param key the key to locate in the map
64          *
65          * @return    ``true`` if key is found, ``false`` otherwise
66          */
67         public abstract bool contains (K key);
68
69         /**
70          * Returns the values for the specified key in this map.
71          *
72          * @param key the key whose values are to be retrieved
73          *
74          * @return    a Collection of values associated with the given key
75          */
76         public abstract Collection<V> get (K key);
77
78         /**
79          * Inserts a key/value pair into this map.
80          *
81          * @param key   the key to insert
82          * @param value the value to associate with the key
83          */
84         public abstract void set (K key, V value);
85
86         /**
87          * Removes the specified key/value pair from this multimap.
88          *
89          * @param key   the key to remove from the map
90          * @param value the value to remove from the map
91          *
92          * @return      ``true`` if the map has been changed, ``false`` otherwise
93          */
94         public abstract bool remove (K key, V value);
95
96         /**
97          * Removes the specified key and all the associated values from this
98          * multimap.
99          *
100          * @param key the key to remove from the map
101          *
102          * @return    ``true`` if the map has been changed, ``false`` otherwise
103          */
104         public abstract bool remove_all (K key);
105
106         /**
107          * Removes all items from this collection.
108          */
109         public abstract void clear ();
110
111         /**
112          * Returns an iterator for this map.
113          *
114          * @return a map iterator
115          */
116         public abstract MapIterator<K, V> map_iterator ();
117
118         /**
119          * The type of the keys in this multimap.
120          */
121         public Type key_type { get { return typeof (K); } }
122
123         /**
124          * The type of the values in this multimap.
125          */
126         public Type value_type { get { return typeof (V); } }
127
128         public virtual MultiMap<K, V> read_only_view {
129                 owned get {
130                         return new ReadOnlyMultiMap<K, V> (this);
131                 }
132         }
133 }