multiblock.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* Copyright 2025 Joaquin M Lopez Munoz.
  2. * Distributed under the Boost Software License, Version 1.0.
  3. * (See accompanying file LICENSE_1_0.txt or copy at
  4. * http://www.boost.org/LICENSE_1_0.txt)
  5. *
  6. * See https://www.boost.org/libs/bloom for library home page.
  7. */
  8. #ifndef BOOST_BLOOM_MULTIBLOCK_HPP
  9. #define BOOST_BLOOM_MULTIBLOCK_HPP
  10. #include <boost/bloom/detail/block_base.hpp>
  11. #include <boost/bloom/detail/block_ops.hpp>
  12. #include <boost/bloom/detail/multiblock_fpr_base.hpp>
  13. #include <boost/config.hpp>
  14. #include <boost/config/workaround.hpp>
  15. #include <cstddef>
  16. #include <cstdint>
  17. namespace boost{
  18. namespace bloom{
  19. template<typename Block,std::size_t K>
  20. struct multiblock:
  21. public detail::multiblock_fpr_base<K>,
  22. private detail::block_base<Block,K>
  23. {
  24. static constexpr std::size_t k=K;
  25. using value_type=Block[k];
  26. /* NOLINTNEXTLINE(readability-redundant-inline-specifier) */
  27. static inline void mark(value_type& x,std::uint64_t hash)
  28. {
  29. std::size_t i=0;
  30. loop(hash,[&](std::uint64_t h){block_ops::set(x[i++],h&mask);});
  31. }
  32. #if BOOST_WORKAROUND(BOOST_MSVC,<=1900)
  33. /* 'int': forcing value to bool 'true' or 'false' */
  34. #pragma warning(push)
  35. #pragma warning(disable:4800)
  36. #endif
  37. /* NOLINTNEXTLINE(readability-redundant-inline-specifier) */
  38. static inline bool check(const value_type& x,std::uint64_t hash)
  39. {
  40. int res=1;
  41. std::size_t i=0;
  42. loop(hash,[&](std::uint64_t h){block_ops::reduce(res,x[i++],h&mask);});
  43. return res;
  44. }
  45. #if BOOST_WORKAROUND(BOOST_MSVC,<=1900)
  46. #pragma warning(pop) /* C4800 */
  47. #endif
  48. private:
  49. using super=detail::block_base<Block,K>;
  50. using super::mask;
  51. using super::loop;
  52. using block_ops=detail::block_ops<Block>;
  53. };
  54. } /* namespace bloom */
  55. } /* namespace boost */
  56. #endif