gtree.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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 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. * Modified by the GLib Team and others 1997-2000. See the AUTHORS
  19. * file for a list of people on the GLib Team. See the ChangeLog
  20. * files for a list of changes. These files are distributed with
  21. * GLib at ftp://ftp.gtk.org/pub/gtk/.
  22. */
  23. #ifndef __G_TREE_H__
  24. #define __G_TREE_H__
  25. #if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
  26. #error "Only <glib.h> can be included directly."
  27. #endif
  28. #include <glib/gnode.h>
  29. G_BEGIN_DECLS
  30. typedef struct _GTree GTree;
  31. typedef gboolean (*GTraverseFunc) (gpointer key,
  32. gpointer value,
  33. gpointer data);
  34. /* Balanced binary trees
  35. */
  36. GLIB_AVAILABLE_IN_ALL
  37. GTree* g_tree_new (GCompareFunc key_compare_func);
  38. GLIB_AVAILABLE_IN_ALL
  39. GTree* g_tree_new_with_data (GCompareDataFunc key_compare_func,
  40. gpointer key_compare_data);
  41. GLIB_AVAILABLE_IN_ALL
  42. GTree* g_tree_new_full (GCompareDataFunc key_compare_func,
  43. gpointer key_compare_data,
  44. GDestroyNotify key_destroy_func,
  45. GDestroyNotify value_destroy_func);
  46. GLIB_AVAILABLE_IN_ALL
  47. GTree* g_tree_ref (GTree *tree);
  48. GLIB_AVAILABLE_IN_ALL
  49. void g_tree_unref (GTree *tree);
  50. GLIB_AVAILABLE_IN_ALL
  51. void g_tree_destroy (GTree *tree);
  52. GLIB_AVAILABLE_IN_ALL
  53. void g_tree_insert (GTree *tree,
  54. gpointer key,
  55. gpointer value);
  56. GLIB_AVAILABLE_IN_ALL
  57. void g_tree_replace (GTree *tree,
  58. gpointer key,
  59. gpointer value);
  60. GLIB_AVAILABLE_IN_ALL
  61. gboolean g_tree_remove (GTree *tree,
  62. gconstpointer key);
  63. GLIB_AVAILABLE_IN_ALL
  64. gboolean g_tree_steal (GTree *tree,
  65. gconstpointer key);
  66. GLIB_AVAILABLE_IN_ALL
  67. gpointer g_tree_lookup (GTree *tree,
  68. gconstpointer key);
  69. GLIB_AVAILABLE_IN_ALL
  70. gboolean g_tree_lookup_extended (GTree *tree,
  71. gconstpointer lookup_key,
  72. gpointer *orig_key,
  73. gpointer *value);
  74. GLIB_AVAILABLE_IN_ALL
  75. void g_tree_foreach (GTree *tree,
  76. GTraverseFunc func,
  77. gpointer user_data);
  78. GLIB_DEPRECATED
  79. void g_tree_traverse (GTree *tree,
  80. GTraverseFunc traverse_func,
  81. GTraverseType traverse_type,
  82. gpointer user_data);
  83. GLIB_AVAILABLE_IN_ALL
  84. gpointer g_tree_search (GTree *tree,
  85. GCompareFunc search_func,
  86. gconstpointer user_data);
  87. GLIB_AVAILABLE_IN_ALL
  88. gint g_tree_height (GTree *tree);
  89. GLIB_AVAILABLE_IN_ALL
  90. gint g_tree_nnodes (GTree *tree);
  91. G_END_DECLS
  92. #endif /* __G_TREE_H__ */