ndtree
nd-octree data-structure and algorithms
bit.hpp File Reference

Bit manipulation utilities. More...

Namespaces

 ndtree
 nd-octree
 
 ndtree::v1::bit
 Bit manipulation utilities.
 

Functions

template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr bool ndtree::v1::bit::has_bit (uint_t b) noexcept
 Does the type Int have the bit b? note: used to assert if bit is within bounds.
 
template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr bool ndtree::v1::bit::get (Int x, uint_t b)
 Gets the value of the i-th bit of the integer x.
 
template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr void ndtree::v1::bit::set (Int &x, uint_t b, bool value)
 Sets the i-th bit of x to value.
 
template<typename Int , Int max = width<Int>, CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr auto ndtree::v1::bit::to_int (Int x, Int from=0, Int to=max) -> Int
 Integer representation of the bit range [from, to) of x.
 
template<typename Int , Int max = width<Int>, CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr auto ndtree::v1::bit::to_int_r (Int x, Int from=0, Int to=max) -> Int
 Reverse integer representation of the bit range [from, to) of x TODO: clean this up.
 
template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
constexpr void ndtree::v1::bit::swap (Int &x, uint_t b0, uint_t b1)
 Swaps the bits a and b in x.
 
template<typename Int , CONCEPT_REQUIRES_(Integral< Int >{}) >
auto ndtree::v1::bit::bits () noexcept
 Range of bit positions for type. More...
 
constexpr uint64_t ndtree::v1::bit::max_value (uint64_t no_bits)
 Maximum representable unsigned integer value in no_bits. More...
 
template<typename UInt , typename SInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}and SignedIntegral< SInt >{}) and bit::width< UInt > = = bit::width<SInt>>
constexpr bool ndtree::v1::bit::overflows_on_add (UInt value, SInt offset, UInt no_bits=width< UInt >)
 Does adding offset to the first no_bits of value overflows?
 
template<typename UInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}) >
constexpr bool ndtree::v1::bit::overflows_on_add (UInt value, UInt offset, UInt no_bits=width< UInt >)
 Does adding offset to the first no_bits of value overflows?
 
template<typename Integral >
constexpr Integral ndtree::v1::bit::deposit_bits (Integral x, Integral mask)
 Parallel Bits Deposit.
 
template<typename Integral >
constexpr Integral ndtree::v1::bit::extract_bits (Integral x, Integral mask)
 Parallel Bits Extract.
 

Variables

template<typename Int >
constexpr auto ndtree::v1::bit::width = static_cast<Int>(CHAR_BIT * sizeof(Int{}))
 Bit width of type Int.
 

1D

template<class UInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}) >
constexpr UInt ndtree::v1::bit::morton::encode (std::array< UInt, 1 > xs) noexcept
 
template<class UInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}) >
constexpr std::array< UInt, 1 > ndtree::v1::bit::morton::decode (UInt code, std::array< UInt, 1 >) noexcept
 

2D

template<class UInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}) >
UInt ndtree::v1::bit::morton::encode (std::array< UInt, 2 > xs) noexcept
 
template<class UInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}) >
std::array< UInt, 2 > ndtree::v1::bit::morton::decode (UInt code, std::array< UInt, 2 >) noexcept
 

3D

template<class UInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}) >
UInt ndtree::v1::bit::morton::encode (std::array< UInt, 3 > xs) noexcept
 
template<class UInt , CONCEPT_REQUIRES_(UnsignedIntegral< UInt >{}) >
std::array< UInt, 3 > ndtree::v1::bit::morton::decode (UInt code, std::array< UInt, 3 >) noexcept
 

Detailed Description

Bit manipulation utilities.