SAvl_header.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /**
  2. * @file SAvl_header.h
  3. * @author Ambroz Bizjak <ambrop7@gmail.com>
  4. *
  5. * @section LICENSE
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. * 1. Redistributions of source code must retain the above copyright
  10. * notice, this list of conditions and the following disclaimer.
  11. * 2. Redistributions in binary form must reproduce the above copyright
  12. * notice, this list of conditions and the following disclaimer in the
  13. * documentation and/or other materials provided with the distribution.
  14. * 3. Neither the name of the author nor the
  15. * names of its contributors may be used to endorse or promote products
  16. * derived from this software without specific prior written permission.
  17. *
  18. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  19. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  21. * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
  22. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  23. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  24. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  25. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  26. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  27. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  28. */
  29. // Preprocessor inputs. All types must be typedef names unless stated otherwise.
  30. // SAVL_PARAM_NAME - name of this data structure
  31. // SAVL_PARAM_FEATURE_COUNTS - whether to keep count information (0 or 1)
  32. // SAVL_PARAM_FEATURE_NOKEYS - define to 1 if there is no need for a lookup operation
  33. // SAVL_PARAM_TYPE_ENTRY - type of entry. This can also be a struct (e.g.: struct Foo).
  34. // SAVL_PARAM_TYPE_KEY - type of key (ignored if SAVL_PARAM_FEATURE_NOKEYS)
  35. // SAVL_PARAM_TYPE_ARG - type of argument pass through to callbacks
  36. // SAVL_PARAM_TYPE_COUNT - type of count (only if SAVL_PARAM_FEATURE_COUNTS)
  37. // SAVL_PARAM_VALUE_COUNT_MAX - maximum value of count (of type SAVL_PARAM_TYPE_COUNT) (only if SAVL_PARAM_FEATURE_COUNTS)
  38. // SAVL_PARAM_FUN_COMPARE_ENTRIES(arg, entry1, entry2) - compare two entries; returns -1/0/1
  39. // SAVL_PARAM_FUN_COMPARE_KEY_ENTRY(arg, key1, entry2) - compare key and entry; returns -1/0/1 (ignored if SAVL_PARAM_FEATURE_NOKEYS)
  40. // SAVL_PARAM_MEMBER_NODE - node member in entry
  41. // types
  42. #define SAvl SAVL_PARAM_NAME
  43. #define SAvlEntry SAVL_PARAM_TYPE_ENTRY
  44. #define SAvlArg SAVL_PARAM_TYPE_ARG
  45. #define SAvlKey SAVL_PARAM_TYPE_KEY
  46. #define SAvlCount SAVL_PARAM_TYPE_COUNT
  47. #define SAvlNode MERGE(SAvl, Node)
  48. // public functions
  49. #define SAvl_Init MERGE(SAvl, _Init)
  50. #define SAvl_Insert MERGE(SAvl, _Insert)
  51. #define SAvl_Remove MERGE(SAvl, _Remove)
  52. #define SAvl_Lookup MERGE(SAvl, _Lookup)
  53. #define SAvl_LookupExact MERGE(SAvl, _LookupExact)
  54. #define SAvl_GetFirstGreater MERGE(SAvl, _GetFirstGreater)
  55. #define SAvl_GetLastLesser MERGE(SAvl, _GetLastLesser)
  56. #define SAvl_GetFirstGreaterEqual MERGE(SAvl, _GetFirstGreaterEqual)
  57. #define SAvl_GetLastLesserEqual MERGE(SAvl, _GetLastLesserEqual)
  58. #define SAvl_GetFirst MERGE(SAvl, _GetFirst)
  59. #define SAvl_GetLast MERGE(SAvl, _GetLast)
  60. #define SAvl_GetNext MERGE(SAvl, _GetNext)
  61. #define SAvl_GetPrev MERGE(SAvl, _GetPrev)
  62. #define SAvl_IsEmpty MERGE(SAvl, _IsEmpty)
  63. #define SAvl_Verify MERGE(SAvl, _Verify)
  64. #define SAvl_Count MERGE(SAvl, _Count)
  65. #define SAvl_IndexOf MERGE(SAvl, _IndexOf)
  66. #define SAvl_GetAt MERGE(SAvl, _GetAt)
  67. // internal stuff
  68. #define SAvl__Tree MERGE(SAvl, __Tree)
  69. #define SAvl__TreeRef MERGE(SAvl, __TreeRef)
  70. #define SAvl__TreeLink MERGE(SAvl, __TreeLink)
  71. #define SAvl__TreeDeref MERGE(SAvl, __TreeDeref)
  72. #define SAvl__Tree_Init MERGE(SAvl, __Tree_Init)
  73. #define SAvl__Tree_Insert MERGE(SAvl, __Tree_Insert)
  74. #define SAvl__Tree_Remove MERGE(SAvl, __Tree_Remove)
  75. #define SAvl__Tree_Lookup MERGE(SAvl, __Tree_Lookup)
  76. #define SAvl__Tree_LookupExact MERGE(SAvl, __Tree_LookupExact)
  77. #define SAvl__Tree_GetFirstGreater MERGE(SAvl, __Tree_GetFirstGreater)
  78. #define SAvl__Tree_GetLastLesser MERGE(SAvl, __Tree_GetLastLesser)
  79. #define SAvl__Tree_GetFirstGreaterEqual MERGE(SAvl, __Tree_GetFirstGreaterEqual)
  80. #define SAvl__Tree_GetLastLesserEqual MERGE(SAvl, __Tree_GetLastLesserEqual)
  81. #define SAvl__Tree_GetFirst MERGE(SAvl, __Tree_GetFirst)
  82. #define SAvl__Tree_GetLast MERGE(SAvl, __Tree_GetLast)
  83. #define SAvl__Tree_GetNext MERGE(SAvl, __Tree_GetNext)
  84. #define SAvl__Tree_GetPrev MERGE(SAvl, __Tree_GetPrev)
  85. #define SAvl__Tree_IsEmpty MERGE(SAvl, __Tree_IsEmpty)
  86. #define SAvl__Tree_Verify MERGE(SAvl, __Tree_Verify)
  87. #define SAvl__Tree_Count MERGE(SAvl, __Tree_Count)
  88. #define SAvl__Tree_IndexOf MERGE(SAvl, __Tree_IndexOf)
  89. #define SAvl__Tree_GetAt MERGE(SAvl, __Tree_GetAt)