4
Copyright (C) 2006 Gabor Csardi <csardi@rmki.kfki.hu>
5
MTA RMKI, Konkoly-Thege Miklos st. 29-33, Budapest 1121, Hungary
7
This program is free software; you can redistribute it and/or modify
8
it under the terms of the GNU General Public License as published by
9
the Free Software Foundation; either version 2 of the License, or
10
(at your option) any later version.
12
This program is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
GNU General Public License for more details.
17
You should have received a copy of the GNU General Public License
18
along with this program; if not, write to the Free Software
19
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
28
igraph_hashtable_t ht;
30
const igraph_strvector_t *keys;
33
/* init and destroy */
34
igraph_hashtable_init(&ht);
35
igraph_hashtable_destroy(&ht);
37
/* init, add some elements and destroy */
38
igraph_hashtable_init(&ht);
39
igraph_hashtable_addset(&ht, "color", "green", "red");
40
igraph_hashtable_addset(&ht, "size", "", "4");
41
igraph_hashtable_addset(&ht, "color", "", "grey");
42
igraph_hashtable_addset(&ht, "shape", "", "circle");
43
igraph_hashtable_addset(&ht, "shape", "", "diamond");
44
igraph_hashtable_destroy(&ht);
47
igraph_hashtable_init(&ht);
48
igraph_hashtable_addset(&ht, "color", "green", "red");
49
igraph_hashtable_addset(&ht, "size", "", "4");
50
igraph_hashtable_addset(&ht, "color", "", "grey");
51
igraph_hashtable_addset(&ht, "shape", "", "circle");
52
igraph_hashtable_addset(&ht, "shape", "", "diamond");
53
igraph_hashtable_reset(&ht);
54
igraph_hashtable_addset(&ht, "color", "green", "red");
55
igraph_hashtable_addset(&ht, "size", "", "4");
56
igraph_hashtable_addset(&ht, "color", "", "grey");
57
igraph_hashtable_addset(&ht, "shape", "", "circle");
58
igraph_hashtable_addset(&ht, "shape", "", "diamond");
59
igraph_hashtable_destroy(&ht);
62
igraph_hashtable_init(&ht);
63
igraph_hashtable_addset(&ht, "color", "green", "red");
64
igraph_hashtable_addset(&ht, "size", "", "4");
65
igraph_hashtable_addset(&ht, "color", "", "grey");
66
igraph_hashtable_addset(&ht, "shape", "", "circle");
67
igraph_hashtable_addset(&ht, "shape", "", "diamond");
69
igraph_hashtable_get(&ht, "color", &str);
70
printf("color: %s\n", str);
71
igraph_hashtable_get(&ht, "size", &str);
72
printf("size: %s\n", str);
73
igraph_hashtable_get(&ht, "shape", &str);
74
printf("shape: %s\n", str);
76
igraph_hashtable_reset(&ht);
78
igraph_hashtable_get(&ht, "color", &str);
79
printf("color: %s\n", str);
80
igraph_hashtable_get(&ht, "size", &str);
81
printf("size: %s\n", str);
82
igraph_hashtable_get(&ht, "shape", &str);
83
printf("shape: %s\n", str);
85
igraph_hashtable_getkeys(&ht, &keys);
86
for (i=0; i<igraph_strvector_size(keys); i++) {
87
igraph_strvector_get(keys, i, &str);
92
igraph_hashtable_destroy(&ht);
95
igraph_hashtable_init(&ht);
96
igraph_hashtable_addset2(&ht, "color", "green", "redddd", 3);
97
igraph_hashtable_addset2(&ht, "size", "", "4111", 1);
98
igraph_hashtable_addset2(&ht, "color", "", "greysdsdf", 4);
99
igraph_hashtable_addset2(&ht, "shape", "", "circle", 6);
100
igraph_hashtable_addset(&ht, "shape", "", "diamond");
102
igraph_hashtable_get(&ht, "color", &str);
103
printf("color: %s\n", str);
104
igraph_hashtable_get(&ht, "size", &str);
105
printf("size: %s\n", str);
106
igraph_hashtable_get(&ht, "shape", &str);
107
printf("shape: %s\n", str);
109
igraph_hashtable_reset(&ht);
111
igraph_hashtable_get(&ht, "color", &str);
112
printf("color: %s\n", str);
113
igraph_hashtable_get(&ht, "size", &str);
114
printf("size: %s\n", str);
115
igraph_hashtable_get(&ht, "shape", &str);
116
printf("shape: %s\n", str);
118
igraph_hashtable_getkeys(&ht, &keys);
119
for (i=0; i<igraph_strvector_size(keys); i++) {
120
igraph_strvector_get(keys, i, &str);
125
igraph_hashtable_destroy(&ht);
127
if (!IGRAPH_FINALLY_STACK_EMPTY) return 1;