1 | /* GLIB - Library of useful routines for C programming |
2 | * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald |
3 | * |
4 | * This library is free software; you can redistribute it and/or |
5 | * modify it under the terms of the GNU Lesser General Public |
6 | * License as published by the Free Software Foundation; either |
7 | * version 2.1 of the License, or (at your option) any later version. |
8 | * |
9 | * This library is distributed in the hope that it will be useful, |
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | * Lesser General Public License for more details. |
13 | * |
14 | * You should have received a copy of the GNU Lesser General Public |
15 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
16 | */ |
17 | |
18 | /* |
19 | * Modified by the GLib Team and others 1997-2000. See the AUTHORS |
20 | * file for a list of people on the GLib Team. See the ChangeLog |
21 | * files for a list of changes. These files are distributed with |
22 | * GLib at ftp://ftp.gtk.org/pub/gtk/. |
23 | */ |
24 | |
25 | #ifndef __G_TREE_H__ |
26 | #define __G_TREE_H__ |
27 | |
28 | #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION) |
29 | #error "Only <glib.h> can be included directly." |
30 | #endif |
31 | |
32 | #include <glib/gnode.h> |
33 | |
34 | G_BEGIN_DECLS |
35 | |
36 | #undef G_TREE_DEBUG |
37 | |
38 | typedef struct _GTree GTree; |
39 | |
40 | /** |
41 | * GTreeNode: |
42 | * |
43 | * An opaque type which identifies a specific node in a #GTree. |
44 | * |
45 | * Since: 2.68 |
46 | */ |
47 | typedef struct _GTreeNode GTreeNode; |
48 | |
49 | typedef gboolean (*GTraverseFunc) (gpointer key, |
50 | gpointer value, |
51 | gpointer data); |
52 | |
53 | /** |
54 | * GTraverseNodeFunc: |
55 | * @node: a #GTreeNode |
56 | * @data: user data passed to g_tree_foreach_node() |
57 | * |
58 | * Specifies the type of function passed to g_tree_foreach_node(). It is |
59 | * passed each node, together with the @user_data parameter passed to |
60 | * g_tree_foreach_node(). If the function returns %TRUE, the traversal is |
61 | * stopped. |
62 | * |
63 | * Returns: %TRUE to stop the traversal |
64 | * Since: 2.68 |
65 | */ |
66 | typedef gboolean (*GTraverseNodeFunc) (GTreeNode *node, |
67 | gpointer data); |
68 | |
69 | /* Balanced binary trees |
70 | */ |
71 | GLIB_AVAILABLE_IN_ALL |
72 | GTree* g_tree_new (GCompareFunc key_compare_func); |
73 | GLIB_AVAILABLE_IN_ALL |
74 | GTree* g_tree_new_with_data (GCompareDataFunc key_compare_func, |
75 | gpointer key_compare_data); |
76 | GLIB_AVAILABLE_IN_ALL |
77 | GTree* g_tree_new_full (GCompareDataFunc key_compare_func, |
78 | gpointer key_compare_data, |
79 | GDestroyNotify key_destroy_func, |
80 | GDestroyNotify value_destroy_func); |
81 | GLIB_AVAILABLE_IN_2_68 |
82 | GTreeNode *g_tree_node_first (GTree *tree); |
83 | GLIB_AVAILABLE_IN_2_68 |
84 | GTreeNode *g_tree_node_last (GTree *tree); |
85 | GLIB_AVAILABLE_IN_2_68 |
86 | GTreeNode *g_tree_node_previous (GTreeNode *node); |
87 | GLIB_AVAILABLE_IN_2_68 |
88 | GTreeNode *g_tree_node_next (GTreeNode *node); |
89 | GLIB_AVAILABLE_IN_ALL |
90 | GTree* g_tree_ref (GTree *tree); |
91 | GLIB_AVAILABLE_IN_ALL |
92 | void g_tree_unref (GTree *tree); |
93 | GLIB_AVAILABLE_IN_ALL |
94 | void g_tree_destroy (GTree *tree); |
95 | GLIB_AVAILABLE_IN_2_68 |
96 | GTreeNode *g_tree_insert_node (GTree *tree, |
97 | gpointer key, |
98 | gpointer value); |
99 | GLIB_AVAILABLE_IN_ALL |
100 | void g_tree_insert (GTree *tree, |
101 | gpointer key, |
102 | gpointer value); |
103 | GLIB_AVAILABLE_IN_2_68 |
104 | GTreeNode *g_tree_replace_node (GTree *tree, |
105 | gpointer key, |
106 | gpointer value); |
107 | GLIB_AVAILABLE_IN_ALL |
108 | void g_tree_replace (GTree *tree, |
109 | gpointer key, |
110 | gpointer value); |
111 | GLIB_AVAILABLE_IN_ALL |
112 | gboolean g_tree_remove (GTree *tree, |
113 | gconstpointer key); |
114 | |
115 | GLIB_AVAILABLE_IN_2_70 |
116 | void g_tree_remove_all (GTree *tree); |
117 | |
118 | GLIB_AVAILABLE_IN_ALL |
119 | gboolean g_tree_steal (GTree *tree, |
120 | gconstpointer key); |
121 | GLIB_AVAILABLE_IN_2_68 |
122 | gpointer g_tree_node_key (GTreeNode *node); |
123 | GLIB_AVAILABLE_IN_2_68 |
124 | gpointer g_tree_node_value (GTreeNode *node); |
125 | GLIB_AVAILABLE_IN_2_68 |
126 | GTreeNode *g_tree_lookup_node (GTree *tree, |
127 | gconstpointer key); |
128 | GLIB_AVAILABLE_IN_ALL |
129 | gpointer g_tree_lookup (GTree *tree, |
130 | gconstpointer key); |
131 | GLIB_AVAILABLE_IN_ALL |
132 | gboolean g_tree_lookup_extended (GTree *tree, |
133 | gconstpointer lookup_key, |
134 | gpointer *orig_key, |
135 | gpointer *value); |
136 | GLIB_AVAILABLE_IN_ALL |
137 | void g_tree_foreach (GTree *tree, |
138 | GTraverseFunc func, |
139 | gpointer user_data); |
140 | GLIB_AVAILABLE_IN_2_68 |
141 | void g_tree_foreach_node (GTree *tree, |
142 | GTraverseNodeFunc func, |
143 | gpointer user_data); |
144 | |
145 | GLIB_DEPRECATED |
146 | void g_tree_traverse (GTree *tree, |
147 | GTraverseFunc traverse_func, |
148 | GTraverseType traverse_type, |
149 | gpointer user_data); |
150 | |
151 | GLIB_AVAILABLE_IN_2_68 |
152 | GTreeNode *g_tree_search_node (GTree *tree, |
153 | GCompareFunc search_func, |
154 | gconstpointer user_data); |
155 | GLIB_AVAILABLE_IN_ALL |
156 | gpointer g_tree_search (GTree *tree, |
157 | GCompareFunc search_func, |
158 | gconstpointer user_data); |
159 | GLIB_AVAILABLE_IN_2_68 |
160 | GTreeNode *g_tree_lower_bound (GTree *tree, |
161 | gconstpointer key); |
162 | GLIB_AVAILABLE_IN_2_68 |
163 | GTreeNode *g_tree_upper_bound (GTree *tree, |
164 | gconstpointer key); |
165 | GLIB_AVAILABLE_IN_ALL |
166 | gint g_tree_height (GTree *tree); |
167 | GLIB_AVAILABLE_IN_ALL |
168 | gint g_tree_nnodes (GTree *tree); |
169 | |
170 | #ifdef G_TREE_DEBUG |
171 | /*< private >*/ |
172 | #ifndef __GTK_DOC_IGNORE__ |
173 | void g_tree_dump (GTree *tree); |
174 | #endif /* !__GTK_DOC_IGNORE__ */ |
175 | #endif /* G_TREE_DEBUG */ |
176 | |
177 | G_END_DECLS |
178 | |
179 | #endif /* __G_TREE_H__ */ |
180 | |