1
0

bintree_find.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 *lub_bintree_find(lub_bintree_t * this, const void *clientkey)
  36. {
  37. this->root = lub_bintree_splay(this, this->root, clientkey);
  38. if (NULL != this->root) {
  39. if (lub_bintree_compare(this, this->root, clientkey) == 0)
  40. return lub_bintree_getclientnode(this, this->root);
  41. }
  42. return NULL;
  43. }
  44. /*--------------------------------------------------------- */