7 #ifndef INCLUDED_SDSL_SORTED_STACK_SUPPORT
8 #define INCLUDED_SDSL_SORTED_STACK_SUPPORT
50 bool empty()
const {
return 0 == m_cnt; };
72 void load(std::istream & in);
73 template <
typename archive_t>
75 template <
typename archive_t>
93 assert(
empty() ==
false);
99 assert((
empty() or
top() < x) and x <= m_n);
103 m_stack[bn] ^= (1ULL << block_pos(x));
104 if (bn > 0 and m_stack[bn - 1] == 0) { m_stack[bn - 1] = 0x8000000000000000ULL | m_top; }
114 uint64_t w = m_stack[bn];
115 assert((w >> 63) == 0);
116 w ^= (1ULL << block_pos(m_top));
118 if (w > 0) { m_top = bn * 63 +
bits::hi(w); }
126 m_top = (bn - 1) * 63 +
bits::hi(w);
131 m_top = w & 0x7FFFFFFFFFFFFFFFULL;
139 std::string name)
const
148 return written_bytes;
159 template <
typename archive_t>
168 template <
typename archive_t>
180 return (m_n == other.m_n) && (m_cnt == other.m_cnt) && (m_top == other.m_top) && (m_stack == other.m_stack);
186 return !(*
this == other);
A generic vector class for integers of width .
void load(std::istream &in)
Load the int_vector for a stream.
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the int_vector to a stream.
A stack which contains strictly increasing numbers in the range from to .
size_type top() const
Returns the topmost index on the stack.
int_vector< 64 >::size_type size_type
sorted_stack_support & operator=(sorted_stack_support &&)=default
sorted_stack_support(const sorted_stack_support &)=default
bool operator==(sorted_stack_support const &other) const noexcept
Equality operator.
void pop()
Pop the topmost index of the stack.
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
bool empty() const
Returns if the stack is empty.
void CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
sorted_stack_support(sorted_stack_support &&)=default
sorted_stack_support & operator=(const sorted_stack_support &)=default
bool operator!=(sorted_stack_support const &other) const noexcept
Inequality operator.
sorted_stack_support(size_type n)
Constructor.
void load(std::istream &in)
void CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
void push(size_type x)
Push the index x of vector vec onto the stack.
size_type size() const
Returns the number of element is the stack.
static void add_size(structure_tree_node *v, uint64_t value)
static structure_tree_node * add_child(structure_tree_node *v, const std::string &name, const std::string &type)
int_vector.hpp contains the sdsl::int_vector class.
Namespace for the succinct data structure library.
size_t write_member(const T &t, std::ostream &out, sdsl::structure_tree_node *v=nullptr, std::string name="")
void read_member(T &t, std::istream &in)
static SDSL_CONSTEXPR uint32_t hi(uint64_t x)
Position of the most significant set bit the 64-bit word x.