Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-08-17 08:39:05

0001 /* Copyright 2025 Joaquin M Lopez Munoz.
0002  * Distributed under the Boost Software License, Version 1.0.
0003  * (See accompanying file LICENSE_1_0.txt or copy at
0004  * http://www.boost.org/LICENSE_1_0.txt)
0005  *
0006  * See https://www.boost.org/libs/bloom for library home page.
0007  */
0008 
0009 #ifndef BOOST_BLOOM_DETAIL_BLOCK_OPS_HPP
0010 #define BOOST_BLOOM_DETAIL_BLOCK_OPS_HPP
0011 
0012 #include <boost/config.hpp>
0013 #include <cstdint>
0014 #include <type_traits>
0015 
0016 namespace boost{
0017 namespace bloom{
0018 namespace detail{
0019 
0020 #if defined(BOOST_MSVC)
0021 #pragma warning(push)
0022 #pragma warning(disable:4714) /* marked as __forceinline not inlined */
0023 #endif
0024 
0025 template<typename Block>
0026 struct block_ops
0027 {
0028   using is_extended_block=std::false_type;
0029   using value_type=Block;
0030 
0031   static BOOST_FORCEINLINE void zero(Block& x)
0032   {
0033     x=0;
0034   }
0035 
0036   static BOOST_FORCEINLINE void set(value_type& x,std::uint64_t n)
0037   {
0038     x|=Block(1)<<n;
0039   }
0040 
0041   static BOOST_FORCEINLINE int get_at_lsb(const value_type& x,std::uint64_t n)
0042   {
0043     return static_cast<int>(x>>n);
0044   }
0045 
0046   static BOOST_FORCEINLINE void reduce(
0047     int& res,const value_type& x,std::uint64_t n)
0048   {
0049     res&=get_at_lsb(x,n);
0050   }
0051 
0052   static BOOST_FORCEINLINE bool testc(const value_type& x,const value_type& y)
0053   {
0054     return (x&y)==y;
0055   }
0056 };
0057 
0058 template<typename Block,std::size_t N>
0059 struct block_ops<Block[N]>
0060 {
0061   using is_extended_block=std::true_type;
0062   using value_type=Block[N];
0063 
0064   static BOOST_FORCEINLINE void zero(value_type& x)
0065   {
0066     for(std::size_t i=0;i<N;++i)x[i]=0;
0067   }
0068 
0069   static BOOST_FORCEINLINE void set(value_type& x,std::uint64_t n)
0070   {
0071     x[n%N]|=Block(1)<<(n/N);
0072   }
0073 
0074   static BOOST_FORCEINLINE int get_at_lsb(const value_type& x,std::uint64_t n)
0075   {
0076     return static_cast<int>(x[n%N]>>(n/N));
0077   }
0078 
0079   static BOOST_FORCEINLINE void reduce(
0080     int& res,const value_type& x,std::uint64_t n)
0081   {
0082     res&=get_at_lsb(x,n);
0083   }
0084 };
0085 
0086 #if defined(BOOST_MSVC)
0087 #pragma warning(pop) /* C4714 */
0088 #endif
0089 
0090 
0091 } /* namespace detail */
0092 } /* namespace bloom */
0093 } /* namespace boost */
0094 
0095 #endif