Line data Source code
1 : /* map.vala
2 : *
3 : * Copyright (C) 2007 Jürg Billeter
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 : * Jürg Billeter <j@bitron.ch>
21 : */
22 :
23 : /**
24 : * A map is a generic collection of key/value pairs.
25 : */
26 67102338 : public abstract class Vala.Map<K,V> {
27 : /**
28 : * The number of items in this map.
29 : */
30 8530 : public abstract int size { get; }
31 :
32 : /**
33 : * Returns the keys of this map as a read-only set.
34 : *
35 : * @return the keys of the map
36 : */
37 4913562 : public abstract Set<K> get_keys ();
38 :
39 : /**
40 : * Returns the values of this map as a read-only collection.
41 : *
42 : * @return the values of the map
43 : */
44 3 : public abstract Collection<V> get_values ();
45 :
46 : /**
47 : * Determines whether this map contains the specified key.
48 : *
49 : * @param key the key to locate in the map
50 : *
51 : * @return true if key is found, false otherwise
52 : */
53 1388808 : public abstract bool contains (K key);
54 :
55 : /**
56 : * Returns the value of the specified key in this map.
57 : *
58 : * @param key the key whose value is to be retrieved
59 : *
60 : * @return the value associated with the key, or null if the key
61 : * couldn't be found
62 : */
63 98411206 : public abstract V? get (K key);
64 :
65 : /**
66 : * Inserts a new key and value into this map.
67 : *
68 : * @param key the key to insert
69 : * @param value the value to associate with the key
70 : */
71 39547408 : public abstract void set (K key, V value);
72 :
73 : /**
74 : * Removes the specified key from this map.
75 : *
76 : * @param key the key to remove from the map
77 : *
78 : * @return true if the map has been changed, false otherwise
79 : */
80 103 : public abstract bool remove (K key);
81 :
82 : /**
83 : * Removes all items from this collection. Must not be called on
84 : * read-only collections.
85 : */
86 16609460 : public abstract void clear ();
87 :
88 : /**
89 : * Returns a Iterator that can be used for simple iteration over a
90 : * map.
91 : *
92 : * @return a Iterator that can be used for simple iteration over a
93 : * map
94 : */
95 1662 : public abstract MapIterator<K,V> map_iterator ();
96 : }
97 :
|