mixed_union.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * mixed_intersection.h
  3. *
  4. */
  5. #ifndef INCLUDE_CONTAINERS_MIXED_UNION_H_
  6. #define INCLUDE_CONTAINERS_MIXED_UNION_H_
  7. /* These functions appear to exclude cases where the
  8. * inputs have the same type and the output is guaranteed
  9. * to have the same type as the inputs. Eg, bitset unions
  10. */
  11. #include <roaring/containers/array.h>
  12. #include <roaring/containers/bitset.h>
  13. #include <roaring/containers/run.h>
  14. #ifdef __cplusplus
  15. extern "C" {
  16. namespace roaring {
  17. namespace internal {
  18. #endif
  19. /* Compute the union of src_1 and src_2 and write the result to
  20. * dst. It is allowed for src_2 to be dst. */
  21. void array_bitset_container_union(const array_container_t *src_1,
  22. const bitset_container_t *src_2,
  23. bitset_container_t *dst);
  24. /* Compute the union of src_1 and src_2 and write the result to
  25. * dst. It is allowed for src_2 to be dst. This version does not
  26. * update the cardinality of dst (it is set to BITSET_UNKNOWN_CARDINALITY). */
  27. void array_bitset_container_lazy_union(const array_container_t *src_1,
  28. const bitset_container_t *src_2,
  29. bitset_container_t *dst);
  30. /*
  31. * Compute the union between src_1 and src_2 and write the result
  32. * to *dst. If the return function is true, the result is a bitset_container_t
  33. * otherwise is a array_container_t. We assume that dst is not pre-allocated. In
  34. * case of failure, *dst will be NULL.
  35. */
  36. bool array_array_container_union(const array_container_t *src_1,
  37. const array_container_t *src_2,
  38. container_t **dst);
  39. /*
  40. * Compute the union between src_1 and src_2 and write the result
  41. * to *dst if it cannot be written to src_1. If the return function is true,
  42. * the result is a bitset_container_t
  43. * otherwise is a array_container_t. When the result is an array_container_t, it
  44. * it either written to src_1 (if *dst is null) or to *dst.
  45. * If the result is a bitset_container_t and *dst is null, then there was a
  46. * failure.
  47. */
  48. bool array_array_container_inplace_union(array_container_t *src_1,
  49. const array_container_t *src_2,
  50. container_t **dst);
  51. /*
  52. * Same as array_array_container_union except that it will more eagerly produce
  53. * a bitset.
  54. */
  55. bool array_array_container_lazy_union(const array_container_t *src_1,
  56. const array_container_t *src_2,
  57. container_t **dst);
  58. /*
  59. * Same as array_array_container_inplace_union except that it will more eagerly
  60. * produce a bitset.
  61. */
  62. bool array_array_container_lazy_inplace_union(array_container_t *src_1,
  63. const array_container_t *src_2,
  64. container_t **dst);
  65. /* Compute the union of src_1 and src_2 and write the result to
  66. * dst. We assume that dst is a
  67. * valid container. The result might need to be further converted to array or
  68. * bitset container,
  69. * the caller is responsible for the eventual conversion. */
  70. void array_run_container_union(const array_container_t *src_1,
  71. const run_container_t *src_2,
  72. run_container_t *dst);
  73. /* Compute the union of src_1 and src_2 and write the result to
  74. * src2. The result might need to be further converted to array or
  75. * bitset container,
  76. * the caller is responsible for the eventual conversion. */
  77. void array_run_container_inplace_union(const array_container_t *src_1,
  78. run_container_t *src_2);
  79. /* Compute the union of src_1 and src_2 and write the result to
  80. * dst. It is allowed for dst to be src_2.
  81. * If run_container_is_full(src_1) is true, you must not be calling this
  82. *function.
  83. **/
  84. void run_bitset_container_union(const run_container_t *src_1,
  85. const bitset_container_t *src_2,
  86. bitset_container_t *dst);
  87. /* Compute the union of src_1 and src_2 and write the result to
  88. * dst. It is allowed for dst to be src_2. This version does not
  89. * update the cardinality of dst (it is set to BITSET_UNKNOWN_CARDINALITY).
  90. * If run_container_is_full(src_1) is true, you must not be calling this
  91. * function.
  92. * */
  93. void run_bitset_container_lazy_union(const run_container_t *src_1,
  94. const bitset_container_t *src_2,
  95. bitset_container_t *dst);
  96. #ifdef __cplusplus
  97. }
  98. }
  99. } // extern "C" { namespace roaring { namespace internal {
  100. #endif
  101. #endif /* INCLUDE_CONTAINERS_MIXED_UNION_H_ */