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
35
igraph_trie_init(&trie, 0);
37
/* add and get values */
38
igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id);
39
igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id);
40
igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id);
41
igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id);
43
igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id);
44
igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id);
45
igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id);
46
igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id);
48
igraph_trie_get(&trie, "a", &id); printf("a: %li\n", id);
49
igraph_trie_get(&trie, "axon", &id); printf("axon: %li\n", id);
51
igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id);
52
igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id);
53
igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id);
54
igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id);
56
/* check for existence */
57
igraph_trie_check(&trie, "head", &id); printf("head: %li\n", id);
58
igraph_trie_check(&trie, "alma", &id); printf("alma: %li\n", id);
61
igraph_trie_destroy(&trie);
63
/* the same with index */
64
igraph_trie_init(&trie, 1);
66
igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id);
67
igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id);
68
igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id);
69
igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id);
71
igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id);
72
igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id);
73
igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id);
74
igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id);
76
igraph_trie_get(&trie, "a", &id); printf("a: %li\n", id);
77
igraph_trie_get(&trie, "axon", &id); printf("axon: %li\n", id);
79
igraph_trie_get(&trie, "hello", &id); printf("hello: %li\n", id);
80
igraph_trie_get(&trie, "hepp", &id); printf("hepp: %li\n", id);
81
igraph_trie_get(&trie, "alma", &id); printf("alma: %li\n", id);
82
igraph_trie_get(&trie, "also", &id); printf("also: %li\n", id);
84
/* check for existence */
85
igraph_trie_check(&trie, "head", &id); printf("head: %li\n", id);
86
igraph_trie_check(&trie, "alma", &id); printf("alma: %li\n", id);
88
for (i=0; i<igraph_trie_size(&trie); i++) {
89
igraph_trie_idx(&trie, i, &str);
90
printf("%d: %s\n", i, str);
92
igraph_trie_destroy(&trie);
94
if (!IGRAPH_FINALLY_STACK_EMPTY) return 1;