8#ifndef INCLUDED_SDSL_UINT128
9#define INCLUDED_SDSL_UINT128
20typedef unsigned int uint128_t __attribute__((mode(TI)));
34 inline uint128_t(uint64_t lo = 0, uint64_t high = 0)
45 : m_lo(std::move(x.m_lo))
46 , m_high(std::move(x.m_high))
58 m_lo = std::move(x.m_lo);
59 m_high = std::move(x.m_high);
65 inline uint16_t
hi()
const
67 if (m_high == 0ULL) {
return bits::hi(m_lo); }
74 inline uint16_t
select(uint32_t i)
const
96 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_lo, m_high - x.m_high - ((m_lo - x.m_lo) > m_lo));
136 auto high = (m_high << x) | (m_lo >> (64 - x));
142 auto high = m_lo << (x - 64);
151 auto lo = (m_lo >> x) | (m_high << (64 - x));
156 auto lo = m_high >> (x - 64);
170 inline bool operator==(
const uint64_t & x)
const {
return (m_lo == x) and (m_high == 0); }
176 if (m_high != x.m_high) {
return m_high > x.m_high; }
179 return m_lo >= x.m_lo;
185 if (m_high != x.m_high) {
return m_high < x.m_high; }
188 return m_lo <= x.m_lo;
194 if (m_high != x.m_high) {
return m_high > x.m_high; }
197 return m_lo > x.m_lo;
203 if (m_high > 0) {
return true; }
209 if (m_high != x.m_high) {
return m_high < x.m_high; }
212 return m_lo < x.m_lo;
216 inline operator uint64_t()
const {
return m_lo; }
222 uint64_t X[2] = { (uint64_t)(x >> 64), (uint64_t)x };
223 for (
int j = 0; j < 2; ++j)
225 for (
int i = 0; i < 16; ++i)
227 os << std::hex << ((X[j] >> 60) & 0xFULL) << std::dec;
bits.hpp contains the sdsl::bits class.
uint128_t operator<<(int x) const
uint128_t operator&(const uint128_t &x) const
uint128_t operator>>(int x) const
bool operator>(const uint128_t &x) const
uint128_t operator-(const uint128_t &x) const
bool operator<=(const uint128_t &x) const
uint128_t(const uint128_t &x)
uint128_t operator+(const uint128_t &x) const
bool operator>=(const uint128_t &x) const
uint128_t(uint64_t lo=0, uint64_t high=0)
uint128_t & operator+=(const uint128_t &x)
uint128_t & operator=(const uint128_t &x)
uint128_t & operator-=(const uint128_t &x)
uint128_t operator+(const uint64_t &x) const
uint128_t operator|(const uint128_t &x) const
uint128_t & operator=(const uint64_t &x)
uint128_t & operator|=(const uint128_t &x)
friend std::ostream & operator<<(std::ostream &, const uint128_t &)
bool operator==(const uint64_t &x) const
uint128_t operator~() const
uint128_t operator|(const uint64_t &x) const
bool operator<(const uint128_t &x) const
bool operator>(const uint64_t &x) const
bool operator==(const uint128_t &x) const
uint16_t select(uint32_t i) const
uint128_t & operator+=(const uint64_t &x)
uint128_t & operator=(uint128_t &&x)
bool operator!=(const uint128_t &x) const
Namespace for the succinct data structure library.
std::ostream & operator<<(std::ostream &os, const bp_interval< t_int > &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.