tree.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. (c) Copyright 2001-2009 The world wide DirectFB Open Source Community (directfb.org)
  3. (c) Copyright 2000-2004 Convergence (integrated media) GmbH
  4. All rights reserved.
  5. Written by Denis Oliver Kropp <dok@directfb.org>,
  6. Andreas Hundt <andi@fischlustig.de>,
  7. Sven Neumann <neo@directfb.org>,
  8. Ville Syrjälä <syrjala@sci.fi> and
  9. Claudio Ciccani <klan@users.sf.net>.
  10. Balanced binary tree ported from glib by Sven Neumann
  11. <sven@convergence.de>.
  12. This library is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU Lesser General Public
  14. License as published by the Free Software Foundation; either
  15. version 2 of the License, or (at your option) any later version.
  16. This library is distributed in the hope that it will be useful,
  17. but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. Lesser General Public License for more details.
  20. You should have received a copy of the GNU Lesser General Public
  21. License along with this library; if not, write to the
  22. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  23. Boston, MA 02111-1307, USA.
  24. */
  25. #ifndef __DIRECT__TREE_H__
  26. #define __DIRECT__TREE_H__
  27. #include <direct/types.h>
  28. typedef struct __D_DirectNode DirectNode;
  29. struct __D_DirectTree
  30. {
  31. DirectNode *root;
  32. void *fast_keys[128];
  33. };
  34. struct __D_DirectNode
  35. {
  36. int balance;
  37. DirectNode *left;
  38. DirectNode *right;
  39. void *key;
  40. void *value;
  41. };
  42. DirectTree *direct_tree_new ( void );
  43. void direct_tree_destroy( DirectTree *tree );
  44. void direct_tree_insert ( DirectTree *tree,
  45. void *key,
  46. void *value );
  47. void *direct_tree_lookup ( DirectTree *tree,
  48. void *key );
  49. #endif