File: map.c

package info (click to toggle)
vala 0.3.4-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 13,756 kB
  • ctags: 12,353
  • sloc: ansic: 116,516; sh: 9,897; yacc: 1,218; makefile: 837; xml: 657; lex: 285
file content (136 lines) | stat: -rw-r--r-- 3,662 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/* map.vala
 *
 * Copyright (C) 2007  Jürg Billeter
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Jürg Billeter <j@bitron.ch>
 */

#include <gee/map.h>







/**
 * Returns the keys of this map as a read-only set.
 *
 * @return the keys of the map
 */
GeeSet* gee_map_get_keys (GeeMap* self) {
	return GEE_MAP_GET_INTERFACE (self)->get_keys (self);
}


/**
 * Returns the values of this map as a read-only collection.
 *
 * @return the values of the map
 */
GeeCollection* gee_map_get_values (GeeMap* self) {
	return GEE_MAP_GET_INTERFACE (self)->get_values (self);
}


/**
 * Determines whether this map contains the specified key.
 *
 * @param key the key to locate in the map
 *
 * @return    true if key is found, false otherwise
 */
gboolean gee_map_contains (GeeMap* self, gconstpointer key) {
	return GEE_MAP_GET_INTERFACE (self)->contains (self, key);
}


/**
 * Returns the value of the specified key in this map.
 *
 * @param key the key whose value is to be retrieved
 *
 * @return    the value associated with the key, or null if the key
 *            couldn't be found
 */
gpointer gee_map_get (GeeMap* self, gconstpointer key) {
	return GEE_MAP_GET_INTERFACE (self)->get (self, key);
}


/**
 * Inserts a new key and value into this map.
 *
 * @param key   the key to insert
 * @param value the value to associate with the key
 */
void gee_map_set (GeeMap* self, gconstpointer key, gconstpointer value) {
	GEE_MAP_GET_INTERFACE (self)->set (self, key, value);
}


/**
 * Removes the specified key from this map.
 *
 * @param key the key to remove from the map
 *
 * @return    true if the map has been changed, false otherwise
 */
gboolean gee_map_remove (GeeMap* self, gconstpointer key) {
	return GEE_MAP_GET_INTERFACE (self)->remove (self, key);
}


/**
 * Removes all items from this collection. Must not be called on
 * read-only collections.
 */
void gee_map_clear (GeeMap* self) {
	GEE_MAP_GET_INTERFACE (self)->clear (self);
}


gint gee_map_get_size (GeeMap* self) {
	gint value;
	g_object_get (G_OBJECT (self), "size", &value, NULL);
	return value;
}


static void gee_map_base_init (GeeMapIface * iface) {
	static gboolean initialized = FALSE;
	if (!initialized) {
		initialized = TRUE;
		g_object_interface_install_property (iface, g_param_spec_int ("size", "size", "size", G_MININT, G_MAXINT, 0, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
	}
}


GType gee_map_get_type (void) {
	static GType gee_map_type_id = 0;
	if (G_UNLIKELY (gee_map_type_id == 0)) {
		static const GTypeInfo g_define_type_info = { sizeof (GeeMapIface), (GBaseInitFunc) gee_map_base_init, (GBaseFinalizeFunc) NULL, (GClassInitFunc) NULL, (GClassFinalizeFunc) NULL, NULL, 0, 0, (GInstanceInitFunc) NULL };
		gee_map_type_id = g_type_register_static (G_TYPE_INTERFACE, "GeeMap", &g_define_type_info, 0);
		g_type_interface_add_prerequisite (gee_map_type_id, G_TYPE_OBJECT);
	}
	return gee_map_type_id;
}