tif_hash_set.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /**********************************************************************
  2. * $Id$
  3. *
  4. * Name: tif_hash_set.h
  5. * Project: TIFF - Common Portability Library
  6. * Purpose: Hash set functions.
  7. * Author: Even Rouault, <even dot rouault at spatialys.com>
  8. *
  9. **********************************************************************
  10. * Copyright (c) 2008-2009, Even Rouault <even dot rouault at spatialys.com>
  11. *
  12. * Permission is hereby granted, free of charge, to any person obtaining a
  13. * copy of this software and associated documentation files (the "Software"),
  14. * to deal in the Software without restriction, including without limitation
  15. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  16. * and/or sell copies of the Software, and to permit persons to whom the
  17. * Software is furnished to do so, subject to the following conditions:
  18. *
  19. * The above copyright notice and this permission notice shall be included
  20. * in all copies or substantial portions of the Software.
  21. *
  22. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  23. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  24. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  25. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  26. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  27. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  28. * DEALINGS IN THE SOFTWARE.
  29. ****************************************************************************/
  30. #ifndef TIFF_HASH_SET_H_INCLUDED
  31. #define TIFF_HASH_SET_H_INCLUDED
  32. #include <stdbool.h>
  33. /**
  34. * \file tif_hash_set.h
  35. *
  36. * Hash set implementation.
  37. *
  38. * An hash set is a data structure that holds elements that are unique
  39. * according to a comparison function. Operations on the hash set, such as
  40. * insertion, removal or lookup, are supposed to be fast if an efficient
  41. * "hash" function is provided.
  42. */
  43. #ifdef __cplusplus
  44. extern "C"
  45. {
  46. #endif
  47. /* Types */
  48. /** Opaque type for a hash set */
  49. typedef struct _TIFFHashSet TIFFHashSet;
  50. /** TIFFHashSetHashFunc */
  51. typedef unsigned long (*TIFFHashSetHashFunc)(const void *elt);
  52. /** TIFFHashSetEqualFunc */
  53. typedef bool (*TIFFHashSetEqualFunc)(const void *elt1, const void *elt2);
  54. /** TIFFHashSetFreeEltFunc */
  55. typedef void (*TIFFHashSetFreeEltFunc)(void *elt);
  56. /* Functions */
  57. TIFFHashSet *TIFFHashSetNew(TIFFHashSetHashFunc fnHashFunc,
  58. TIFFHashSetEqualFunc fnEqualFunc,
  59. TIFFHashSetFreeEltFunc fnFreeEltFunc);
  60. void TIFFHashSetDestroy(TIFFHashSet *set);
  61. int TIFFHashSetSize(const TIFFHashSet *set);
  62. #ifdef notused
  63. void TIFFHashSetClear(TIFFHashSet *set);
  64. /** TIFFHashSetIterEltFunc */
  65. typedef int (*TIFFHashSetIterEltFunc)(void *elt, void *user_data);
  66. void TIFFHashSetForeach(TIFFHashSet *set, TIFFHashSetIterEltFunc fnIterFunc,
  67. void *user_data);
  68. #endif
  69. bool TIFFHashSetInsert(TIFFHashSet *set, void *elt);
  70. void *TIFFHashSetLookup(TIFFHashSet *set, const void *elt);
  71. bool TIFFHashSetRemove(TIFFHashSet *set, const void *elt);
  72. #ifdef notused
  73. bool TIFFHashSetRemoveDeferRehash(TIFFHashSet *set, const void *elt);
  74. #endif
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif /* TIFF_HASH_SET_H_INCLUDED */