private.h 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 *lub_bintree_splay(const lub_bintree_t * tree,
  37. lub_bintree_node_t * t,
  38. const void *key);
  39. /*------------------------------------------------------------ */
  40. /* This operation converts a "node" into a "clientnode"
  41. * subtracting the offset gives the base pointer to the node
  42. *
  43. * this - the tree to invoke this operation upon
  44. * node - the node to convert
  45. */
  46. #define lub_bintree_getclientnode(this,node)\
  47. (void *)(((char*)node) - this->node_offset)
  48. /*------------------------------------------------------------ */
  49. /* This operation converts a "clientnode" into a "node"
  50. * adding the offset gives the base pointer to the node
  51. *
  52. * this - the tree to invoke this operation upon
  53. * clientnode - the clientnode to convert
  54. */
  55. #define lub_bintree_getnode(this,clientnode)\
  56. (lub_bintree_node_t *)(((char*)clientnode) + this->node_offset) /*lint -e826 */
  57. /*------------------------------------------------------------ */
  58. /* This operation compares a key with a "node"
  59. * it returns
  60. * <0 if key < node
  61. * 0 if key == node
  62. * >0 if key > node
  63. *
  64. * this - the tree to invoke this operation upon
  65. * node - the "node" to compare
  66. * key - the key to compare
  67. */
  68. #define lub_bintree_compare(this,node,key)\
  69. (this)->compareFn(lub_bintree_getclientnode(this,node),key)
  70. /*------------------------------------------------------------ */