bintree_find.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*********************** -*- Mode: C -*- ***********************
  2. * File : bintree_find.c
  3. *---------------------------------------------------------------
  4. * Description
  5. * ===========
  6. * This operation searches the specified "tree" for a "clientnode"
  7. * which matches the specified "key"
  8. *
  9. * tree - the "tree" instance to invoke this operation upon
  10. * key - the "key" to search with
  11. *
  12. * RETURNS
  13. * "clientnode" instance or NULL if no node is found.
  14. *---------------------------------------------------------------
  15. * Author : Graeme McKerrell
  16. * Created On : Wed Jan 28 10:29:54 2004
  17. * Status : TESTED
  18. *---------------------------------------------------------------
  19. * HISTORY
  20. * 7-Dec-2004 Graeme McKerrell
  21. * Renamed to the "lub_" namespace
  22. * 5-May-2004 Graeme McKerrell
  23. * updates following review
  24. * 27-Feb-2004 Graeme McKerrell
  25. * Fixed to account for empty tree
  26. * 9-Feb-2004 Graeme McKerrell
  27. * update to use new node,key comparison ordering
  28. * 28-Jan-2004 Graeme McKerrell
  29. * Initial version
  30. *---------------------------------------------------------------
  31. * Copyright (C) 2004 3Com Corporation. All Rights Reserved.
  32. **************************************************************** */
  33. #include "private.h"
  34. /*--------------------------------------------------------- */
  35. void *
  36. lub_bintree_find(lub_bintree_t *this,
  37. const void *clientkey)
  38. {
  39. this->root = lub_bintree_splay(this,this->root,clientkey);
  40. if(NULL != this->root)
  41. {
  42. if(lub_bintree_compare(this,this->root,clientkey) == 0)
  43. return lub_bintree_getclientnode(this,this->root);
  44. }
  45. return NULL;
  46. }
  47. /*--------------------------------------------------------- */