8#ifndef INCLUDED_SDSL_UINT128
9#define INCLUDED_SDSL_UINT128
19typedef unsigned int uint128_t __attribute__((mode(TI)));
33 inline uint128_t(uint64_t lo = 0, uint64_t high = 0) : m_lo(lo), m_high(high)
51 m_lo = std::move(x.m_lo);
52 m_high = std::move(x.m_high);
61 inline uint16_t
hi()
const
73 inline uint16_t
select(uint32_t i)
const
98 return uint128_t(m_lo + x.m_lo, m_high + x.m_high + ((m_lo + x.m_lo) < m_lo));
103 return uint128_t(m_lo + x, m_high + ((m_lo + x) < m_lo));
108 return uint128_t(m_lo - x.m_lo, m_high - x.m_high - ((m_lo - x.m_lo) > m_lo));
124 return uint128_t(m_lo | x.m_lo, m_high | x.m_high);
141 return uint128_t(m_lo & x.m_lo, m_high & x.m_high);
153 auto high = (m_high << x) | (m_lo >> (64 - x));
159 auto high = m_lo << (x - 64);
168 auto lo = (m_lo >> x) | (m_high << (64 - x));
173 auto lo = m_high >> (x - 64);
187 return (m_lo == x.m_lo) and (m_high == x.m_high);
192 return (m_lo == x) and (m_high == 0);
197 return !(*
this == x);
202 if (m_high != x.m_high)
204 return m_high > x.m_high;
208 return m_lo >= x.m_lo;
214 if (m_high != x.m_high)
216 return m_high < x.m_high;
220 return m_lo <= x.m_lo;
226 if (m_high != x.m_high)
228 return m_high > x.m_high;
232 return m_lo > x.m_lo;
247 if (m_high != x.m_high)
249 return m_high < x.m_high;
253 return m_lo < x.m_lo;
257 inline operator uint64_t()
const
266 uint64_t X[2] = {(uint64_t)(x >> 64), (uint64_t)x};
267 for (
int j = 0; j < 2; ++j)
269 for (
int i = 0; i < 16; ++i)
271 os << std::hex << ((X[j] >> 60) & 0xFULL) << std::dec;
bool operator>(uint128_t const &x) const
uint128_t operator<<(int x) const
bool operator>(uint64_t const &x) const
uint128_t operator|(uint128_t const &x) const
uint128_t & operator+=(uint64_t const &x)
uint128_t & operator-=(uint128_t const &x)
friend std::ostream & operator<<(std::ostream &, uint128_t const &)
uint128_t operator-(uint128_t const &x) const
uint128_t operator>>(int x) const
uint128_t & operator=(uint64_t const &x)
bool operator<(uint128_t const &x) const
uint128_t operator|(uint64_t const &x) const
uint128_t & operator=(uint128_t const &x)
bool operator>=(uint128_t const &x) const
uint128_t operator+(uint64_t const &x) const
uint128_t operator&(uint128_t const &x) const
bool operator==(uint128_t const &x) const
uint128_t(uint64_t lo=0, uint64_t high=0)
bool operator!=(uint128_t const &x) const
uint128_t(uint128_t const &x)
uint128_t operator~() const
uint128_t operator+(uint128_t const &x) const
bool operator==(uint64_t const &x) const
uint128_t & operator|=(uint128_t const &x)
bool operator<=(uint128_t const &x) const
uint16_t select(uint32_t i) const
uint128_t & operator=(uint128_t &&x)
uint128_t & operator+=(uint128_t const &x)
Namespace for the succinct data structure library.
std::ostream & operator<<(std::ostream &os, bp_interval< t_int > const &interval)
static constexpr uint32_t sel(uint64_t x, uint32_t i)
Calculate the position of the i-th rightmost 1 bit in the 64bit integer x.
static constexpr uint32_t hi(uint64_t x)
Position of the most significant set bit the 64-bit word x.
static constexpr uint64_t cnt(uint64_t x)
Counts the number of set bits in x.