1
0

private.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*********************** -*- Mode: C -*- ***********************
  2. * File : private.h
  3. *---------------------------------------------------------------
  4. * Description
  5. * ===========
  6. * This defines the private interface used internally by this component
  7. *---------------------------------------------------------------
  8. * Author : Graeme McKerrell
  9. * Created On : Wed Jan 28 08:45:01 2004
  10. * Status : TESTED
  11. *---------------------------------------------------------------
  12. * HISTORY
  13. * 7-Dec-2004 Graeme McKerrell
  14. * Renamed to the "lub_" namespace
  15. * 5-May-2004 Graeme McKerrell
  16. * updates following review
  17. * 9-Feb-2004 Graeme McKerrell
  18. * modified compare MACRO
  19. * 28-Jan-2004 Graeme McKerrell
  20. * Initial version
  21. *---------------------------------------------------------------
  22. * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
  23. **************************************************************** */
  24. #include "lub/bintree.h"
  25. /*************************************************************
  26. * PRIVATE OPERATIONS
  27. ************************************************************* */
  28. /*------------------------------------------------------------ */
  29. /* This is the operation which performs a top-down splay. It is
  30. * the core workhorse for this tree implementation.
  31. *
  32. * tree - the instance to invoke this operation upon
  33. * t - the root node to splay to.
  34. * key - the value with which to splay
  35. */
  36. extern lub_bintree_node_t *
  37. lub_bintree_splay(const lub_bintree_t *tree,
  38. lub_bintree_node_t *t,
  39. const void *key);
  40. /*------------------------------------------------------------ */
  41. /* This operation converts a "node" into a "clientnode"
  42. * subtracting the offset gives the base pointer to the node
  43. *
  44. * this - the tree to invoke this operation upon
  45. * node - the node to convert
  46. */
  47. #define lub_bintree_getclientnode(this,node)\
  48. (void *)(((char*)node) - this->node_offset)
  49. /*------------------------------------------------------------ */
  50. /* This operation converts a "clientnode" into a "node"
  51. * adding the offset gives the base pointer to the node
  52. *
  53. * this - the tree to invoke this operation upon
  54. * clientnode - the clientnode to convert
  55. */
  56. #define lub_bintree_getnode(this,clientnode)\
  57. (lub_bintree_node_t *)(((char*)clientnode) + this->node_offset) /*lint -e826 */
  58. /*------------------------------------------------------------ */
  59. /* This operation compares a key with a "node"
  60. * it returns
  61. * <0 if key < node
  62. * 0 if key == node
  63. * >0 if key > node
  64. *
  65. * this - the tree to invoke this operation upon
  66. * node - the "node" to compare
  67. * key - the key to compare
  68. */
  69. #define lub_bintree_compare(this,node,key)\
  70. (this)->compareFn(lub_bintree_getclientnode(this,node),key)
  71. /*------------------------------------------------------------ */