mixed_andnot.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. /*
  2. * mixed_andnot.h
  3. */
  4. #ifndef INCLUDE_CONTAINERS_MIXED_ANDNOT_H_
  5. #define INCLUDE_CONTAINERS_MIXED_ANDNOT_H_
  6. #include <roaring/containers/array.h>
  7. #include <roaring/containers/bitset.h>
  8. #include <roaring/containers/run.h>
  9. #ifdef __cplusplus
  10. extern "C" {
  11. namespace roaring {
  12. namespace internal {
  13. #endif
  14. /* Compute the andnot of src_1 and src_2 and write the result to
  15. * dst, a valid array container that could be the same as dst.*/
  16. void array_bitset_container_andnot(const array_container_t *src_1,
  17. const bitset_container_t *src_2,
  18. array_container_t *dst);
  19. /* Compute the andnot of src_1 and src_2 and write the result to
  20. * src_1 */
  21. void array_bitset_container_iandnot(array_container_t *src_1,
  22. const bitset_container_t *src_2);
  23. /* Compute the andnot of src_1 and src_2 and write the result to
  24. * dst, which does not initially have a valid container.
  25. * Return true for a bitset result; false for array
  26. */
  27. bool bitset_array_container_andnot(const bitset_container_t *src_1,
  28. const array_container_t *src_2,
  29. container_t **dst);
  30. /* Compute the andnot of src_1 and src_2 and write the result to
  31. * dst (which has no container initially). It will modify src_1
  32. * to be dst if the result is a bitset. Otherwise, it will
  33. * free src_1 and dst will be a new array container. In both
  34. * cases, the caller is responsible for deallocating dst.
  35. * Returns true iff dst is a bitset */
  36. bool bitset_array_container_iandnot(bitset_container_t *src_1,
  37. const array_container_t *src_2,
  38. container_t **dst);
  39. /* Compute the andnot of src_1 and src_2 and write the result to
  40. * dst. Result may be either a bitset or an array container
  41. * (returns "result is bitset"). dst does not initially have
  42. * any container, but becomes either a bitset container (return
  43. * result true) or an array container.
  44. */
  45. bool run_bitset_container_andnot(const run_container_t *src_1,
  46. const bitset_container_t *src_2,
  47. container_t **dst);
  48. /* Compute the andnot of src_1 and src_2 and write the result to
  49. * dst. Result may be either a bitset or an array container
  50. * (returns "result is bitset"). dst does not initially have
  51. * any container, but becomes either a bitset container (return
  52. * result true) or an array container.
  53. */
  54. bool run_bitset_container_iandnot(run_container_t *src_1,
  55. const bitset_container_t *src_2,
  56. container_t **dst);
  57. /* Compute the andnot of src_1 and src_2 and write the result to
  58. * dst. Result may be either a bitset or an array container
  59. * (returns "result is bitset"). dst does not initially have
  60. * any container, but becomes either a bitset container (return
  61. * result true) or an array container.
  62. */
  63. bool bitset_run_container_andnot(const bitset_container_t *src_1,
  64. const run_container_t *src_2,
  65. container_t **dst);
  66. /* Compute the andnot of src_1 and src_2 and write the result to
  67. * dst (which has no container initially). It will modify src_1
  68. * to be dst if the result is a bitset. Otherwise, it will
  69. * free src_1 and dst will be a new array container. In both
  70. * cases, the caller is responsible for deallocating dst.
  71. * Returns true iff dst is a bitset */
  72. bool bitset_run_container_iandnot(bitset_container_t *src_1,
  73. const run_container_t *src_2,
  74. container_t **dst);
  75. /* dst does not indicate a valid container initially. Eventually it
  76. * can become any type of container.
  77. */
  78. int run_array_container_andnot(const run_container_t *src_1,
  79. const array_container_t *src_2,
  80. container_t **dst);
  81. /* Compute the andnot of src_1 and src_2 and write the result to
  82. * dst (which has no container initially). It will modify src_1
  83. * to be dst if the result is a bitset. Otherwise, it will
  84. * free src_1 and dst will be a new array container. In both
  85. * cases, the caller is responsible for deallocating dst.
  86. * Returns true iff dst is a bitset */
  87. int run_array_container_iandnot(run_container_t *src_1,
  88. const array_container_t *src_2,
  89. container_t **dst);
  90. /* dst must be a valid array container, allowed to be src_1 */
  91. void array_run_container_andnot(const array_container_t *src_1,
  92. const run_container_t *src_2,
  93. array_container_t *dst);
  94. /* dst does not indicate a valid container initially. Eventually it
  95. * can become any kind of container.
  96. */
  97. void array_run_container_iandnot(array_container_t *src_1,
  98. const run_container_t *src_2);
  99. /* dst does not indicate a valid container initially. Eventually it
  100. * can become any kind of container.
  101. */
  102. int run_run_container_andnot(const run_container_t *src_1,
  103. const run_container_t *src_2, container_t **dst);
  104. /* Compute the andnot of src_1 and src_2 and write the result to
  105. * dst (which has no container initially). It will modify src_1
  106. * to be dst if the result is a bitset. Otherwise, it will
  107. * free src_1 and dst will be a new array container. In both
  108. * cases, the caller is responsible for deallocating dst.
  109. * Returns true iff dst is a bitset */
  110. int run_run_container_iandnot(run_container_t *src_1,
  111. const run_container_t *src_2, container_t **dst);
  112. /*
  113. * dst is a valid array container and may be the same as src_1
  114. */
  115. void array_array_container_andnot(const array_container_t *src_1,
  116. const array_container_t *src_2,
  117. array_container_t *dst);
  118. /* inplace array-array andnot will always be able to reuse the space of
  119. * src_1 */
  120. void array_array_container_iandnot(array_container_t *src_1,
  121. const array_container_t *src_2);
  122. /* Compute the andnot of src_1 and src_2 and write the result to
  123. * dst (which has no container initially). Return value is
  124. * "dst is a bitset"
  125. */
  126. bool bitset_bitset_container_andnot(const bitset_container_t *src_1,
  127. const bitset_container_t *src_2,
  128. container_t **dst);
  129. /* Compute the andnot of src_1 and src_2 and write the result to
  130. * dst (which has no container initially). It will modify src_1
  131. * to be dst if the result is a bitset. Otherwise, it will
  132. * free src_1 and dst will be a new array container. In both
  133. * cases, the caller is responsible for deallocating dst.
  134. * Returns true iff dst is a bitset */
  135. bool bitset_bitset_container_iandnot(bitset_container_t *src_1,
  136. const bitset_container_t *src_2,
  137. container_t **dst);
  138. #ifdef __cplusplus
  139. }
  140. }
  141. } // extern "C" { namespace roaring { namespace internal {
  142. #endif
  143. #endif