8#ifndef INCLUDED_SDSL_INT_VECTOR
9#define INCLUDED_SDSL_INT_VECTOR
17#include <initializer_list>
40template <u
int8_t t_w
idth>
46template <
class t_
int_vector>
48template <
class t_
int_vector>
50template <
class t_
int_vector>
52template <
class t_
int_vector>
54template <u
int8_t, u
int8_t>
56template <u
int8_t, u
int8_t>
71template <u
int8_t t_w
idth>
83template <u
int8_t t_w
idth>
100 return iterator(v, v->size() * v->width());
113 if constexpr (t_width == 0)
114 width = new_width ? std::min(new_width, uint8_t{64u}) : 64u;
210template <u
int8_t t_w
idth>
214 static_assert(t_width <= 64,
"int_vector: width of must be at most 64bits.");
237 template <u
int8_t, std::ios_base::openmode>
239 template <
typename T>
241 template <
typename T>
243 template <
typename T>
265 if constexpr (t_width != 0)
268 if (
bit_size > m_capacity || m_data ==
nullptr)
271 size_type new_capacity = std::max<size_type>(m_capacity, 64u);
282 if (
bit_size > m_capacity || m_data ==
nullptr)
285 size_type new_capacity = std::max<size_type>(m_capacity, 64u);
298 return (m_size + 63) >> 6;
324 template <
typename input_iterator_t>
326 std::is_base_of<std::input_iterator_tag,
327 typename std::iterator_traits<input_iterator_t>::iterator_category>::value,
328 input_iterator_t>::type first,
329 input_iterator_t last) :
349 std::copy(it_nonconst + 1,
end(), it_nonconst);
362 std::copy(last_nonconst,
end(), first_nonconst);
364 return first_nonconst;
371 template <
class... Args>
383 return insert(it, 1, value);
394 amortized_resize(
size() + n);
396 std::copy_backward(it_new,
end() - n,
end());
397 std::fill_n(it_new, n, value);
407 return insert(it, il.begin(), il.end());
415 template <
typename input_iterator_t>
416 typename std::enable_if<std::is_base_of<std::input_iterator_tag,
417 typename std::iterator_traits<input_iterator_t>::iterator_category>::value,
422 amortized_resize(
size() + last - first);
424 std::copy_backward(it_new,
end() - (last - first),
end());
425 std::copy(first, last, it_new);
450 return *(
cend() - 1);
456 template <
class... Args>
467 amortized_resize(
size() + 1);
468 *(
end() - 1) = value;
492 bit_resize(
size * m_width);
499 void assign(std::initializer_list<value_type> il)
501 bit_resize(il.size() * m_width);
513 template <
typename input_iterator_t>
514 void assign(input_iterator_t first, input_iterator_t last)
516 assert(first <= last);
517 bit_resize((last - first) * m_width);
521 (*this)[idx++] = *(first++);
548 if (
capacity * m_width > m_capacity || m_data ==
nullptr)
570 bit_resize(
size * m_width, value);
619 uint64_t
const *
data() const noexcept
664 void width(uint8_t new_width)
noexcept
687 template <
typename archive_t>
688 inline typename std::enable_if<
694 template <
typename archive_t>
695 inline typename std::enable_if<
701 template <
typename archive_t>
702 inline typename std::enable_if<
708 template <
typename archive_t>
709 inline typename std::enable_if<
763 uint64_t
const * data1 = v.data();
764 uint64_t
const * data2 =
data();
765 for (
size_type i = 0; i < bit_data_size() - 1; ++i)
767 if (*(data1++) != *(data2++))
770 uint8_t l = 64 - ((bit_data_size() << 6) - m_size);
781 template <u
int8_t t_w
idth2>
784 return (this->
size() == v.size()) && std::equal(this->
begin(), this->
end(), v.begin());
794 template <u
int8_t t_w
idth2>
797 return !(*
this == v);
873 static_assert(1 == t_width,
"int_vector: flip() is available only for bit_vector.");
876 for (uint64_t i = 0; i < bit_data_size(); ++i)
878 m_data[i] = ~m_data[i];
886 uint64_t width_and_size = 0;
889 uint8_t read_int_width = (uint8_t)(width_and_size >> 56);
892 int_width = read_int_width;
894 if (t_width > 0 and t_width != read_int_width)
896 std::cerr <<
"Warning: Width of int_vector<" << (size_t)t_width <<
">";
897 std::cerr <<
" was specified as " << (
size_type)read_int_width << std::endl;
898 std::cerr <<
"Length is " <<
size <<
" bits" << std::endl;
900 return sizeof(width_and_size);
908 if (t_width != int_width)
910 std::cout <<
"Warning: writing width=" << (
size_type)int_width <<
" != fixed " << (
size_type)t_width
914 uint64_t width_and_size = (((uint64_t)int_width) << 56) |
size;
930 return written_bytes;
940template <
class t_
int_vector>
947 typename t_int_vector::value_type *
const m_word;
948 const uint8_t m_offset;
1009 value_type val = (
typename t_int_vector::value_type) *
this;
1058template <
class t_
int_vector>
1068template <
class t_
int_vector>
1079template <
class t_
int_vector>
1099 uint64_t *
const m_word;
1127 return *
this = bool(x);
1131 return *
this = bool(x);
1135 operator bool() const noexcept
1137 return !!(*m_word & m_mask);
1142 return bool(*
this) == bool(x);
1147 return !bool(*
this) && bool(x);
1181template <
class t_
int_vector>
1203 m_len(v == nullptr ? 0 : v->m_width)
1207template <
class t_
int_vector>
1224 typename t_int_vector::value_type * m_word;
1229 m_word((v != nullptr) ? v->m_data + (idx >> 6) : nullptr)
1288 return *
this -= (-i);
1291 if ((
m_offset += (t & 0x3F)) & ~0x3F)
1302 return *
this += (-i);
1305 if ((
m_offset -= (t & 0x3F)) & ~0x3F)
1338 return *(*
this + i);
1343 return it.m_word == m_word && it.m_offset ==
m_offset;
1348 return !(*
this == it);
1353 if (m_word == it.m_word)
1355 return m_word < it.m_word;
1360 if (m_word == it.m_word)
1362 return m_word > it.m_word;
1367 return !(*
this < it);
1372 return !(*
this > it);
1376 return (((m_word - it.m_word) << 6) +
m_offset - it.m_offset) /
m_len;
1385template <
class t_
int_vector>
1392template <
class t_
int_vector>
1397 typedef const typename t_int_vector::value_type *
pointer;
1412 const typename t_int_vector::value_type * m_word;
1417 m_word((v != nullptr) ? v->m_data + (idx >> 6) : nullptr)
1482 return *
this -= (-i);
1485 if ((
m_offset += (t & 0x3F)) & ~0x3F)
1496 return *
this += (-i);
1499 if ((
m_offset -= (t & 0x3F)) & ~0x3F)
1521 return *(*
this + i);
1526 return it.m_word == m_word && it.m_offset ==
m_offset;
1531 return !(*
this == it);
1536 if (m_word == it.m_word)
1538 return m_word < it.m_word;
1543 if (m_word == it.m_word)
1545 return m_word > it.m_word;
1550 return !(*
this < it);
1555 return !(*
this > it);
1559template <
class t_
int_vector>
1566template <
class t_
int_vector>
1567inline int_vector_const_iterator<t_int_vector>
1574template <
class t_bv>
1575inline typename std::enable_if<std::is_same<typename t_bv::index_category, bv_tag>::value, std::ostream &>::type
1576operator<<(std::ostream & os, t_bv
const & bv)
1587template <u
int8_t t_w
idth>
1598template <u
int8_t t_w
idth>
1601 m_capacity(v.m_capacity),
1610template <u
int8_t t_w
idth>
1621 if (memcpy(m_data, v.
data(), bit_data_size() << 3) ==
nullptr)
1623 throw std::bad_alloc();
1628template <u
int8_t t_w
idth>
1634 *
this = std::move(tmp);
1639template <u
int8_t t_w
idth>
1647 m_width = v.m_width;
1648 m_capacity = v.m_capacity;
1657template <u
int8_t t_w
idth>
1664template <u
int8_t t_w
idth>
1670template <u
int8_t t_w
idth>
1673 if (
size > m_capacity || m_data ==
nullptr)
1680template <u
int8_t t_w
idth>
1683 size_type old_size = m_size;
1685 auto it = begin() + old_size / m_width;
1689template <u
int8_t t_w
idth>
1693 if (idx + len > m_size)
1695 throw std::out_of_range(
"OUT_OF_RANGE_ERROR: int_vector::get_int(size_type, uint8_t); idx+len > size()!");
1699 throw std::out_of_range(
"OUT_OF_RANGE_ERROR: int_vector::get_int(size_type, uint8_t); len>64!");
1705template <u
int8_t t_w
idth>
1709 if (idx + len > m_size)
1711 throw std::out_of_range(
"OUT_OF_RANGE_ERROR: int_vector::set_int(size_type, uint8_t); idx+len > size()!");
1715 throw std::out_of_range(
"OUT_OF_RANGE_ERROR: int_vector::set_int(size_type, uint8_t); len>64!");
1721template <u
int8_t t_w
idth>
1724 return m_size / t_width;
1766 return m_size / m_width;
1769template <u
int8_t t_w
idth>
1772 return m_capacity / t_width;
1779 return m_capacity >> 6;
1786 return m_capacity >> 5;
1793 return m_capacity >> 4;
1800 return m_capacity >> 3;
1814 return m_capacity / m_width;
1817template <u
int8_t t_w
idth>
1820 assert(idx < this->
size());
1822 return reference(this->m_data + (i >> 6), i & 0x3F, m_width);
1829 assert(idx < this->
size());
1830 return *(this->m_data + idx);
1837 assert(idx < this->
size());
1838 return *(((uint32_t *)(this->m_data)) + idx);
1845 assert(idx < this->
size());
1846 return *(((uint16_t *)(this->m_data)) + idx);
1853 assert(idx < this->
size());
1854 return *(((uint8_t *)(this->m_data)) + idx);
1857template <u
int8_t t_w
idth>
1860 assert(idx < this->
size());
1861 return get_int(idx * t_width, t_width);
1867 assert(idx < this->
size());
1868 return get_int(idx * m_width, m_width);
1874 assert(idx < this->
size());
1875 return *(this->m_data + idx);
1881 assert(idx < this->
size());
1882 return *(((uint32_t *)this->m_data) + idx);
1888 assert(idx < this->
size());
1889 return *(((uint16_t *)this->m_data) + idx);
1895 assert(idx < this->
size());
1896 return *(((uint8_t *)this->m_data) + idx);
1902 assert(idx < this->
size());
1903 return ((*(m_data + (idx >> 6))) >> (idx & 0x3F)) & 1;
1906template <u
int8_t t_w
idth>
1910 if (min_size > v.size())
1911 min_size = v.size();
1912 for (
auto it = begin(), end = begin() + min_size, it_v = v.begin(); it != end; ++it, ++it_v)
1922template <u
int8_t t_w
idth>
1926 if (min_size > v.size())
1927 min_size = v.size();
1928 for (
auto it = begin(), end = begin() + min_size, it_v = v.begin(); it != end; ++it, ++it_v)
1938template <u
int8_t t_w
idth>
1941 return *
this == v or *
this < v;
1944template <u
int8_t t_w
idth>
1947 return *
this == v or *
this > v;
1950template <u
int8_t t_w
idth>
1953 assert(v.
bit_size() == bit_size());
1954 for (uint64_t i = 0; i < bit_data_size(); ++i)
1955 m_data[i] &= v.m_data[i];
1959template <u
int8_t t_w
idth>
1962 assert(bit_size() == v.
bit_size());
1963 for (uint64_t i = 0; i < bit_data_size(); ++i)
1964 m_data[i] |= v.m_data[i];
1968template <u
int8_t t_w
idth>
1971 assert(bit_size() == v.
bit_size());
1972 for (uint64_t i = 0; i < bit_data_size(); ++i)
1973 m_data[i] ^= v.m_data[i];
1977template <u
int8_t t_w
idth>
1981 uint64_t * p = m_data;
1990 out.write((
char *)p, (bit_data_size() - idx) *
sizeof(uint64_t));
1991 written_bytes += (bit_data_size() - idx) *
sizeof(uint64_t);
1992 return written_bytes;
1995template <u
int8_t t_w
idth>
2001 written_bytes += write_data(out);
2003 return written_bytes;
2006template <u
int8_t t_w
idth>
2013 uint64_t * p = m_data;
2021 in.read((
char *)p, (bit_data_size() - idx) *
sizeof(uint64_t));
2024template <u
int8_t t_w
idth>
2025template <
typename archive_t>
2026inline typename std::enable_if<
2037template <u
int8_t t_w
idth>
2038template <
typename archive_t>
2039inline typename std::enable_if<
2047 for (value_type
const & v : *this)
2051template <u
int8_t t_w
idth>
2052template <
typename archive_t>
2053inline typename std::enable_if<
2065template <u
int8_t t_w
idth>
2066template <
typename archive_t>
2067inline typename std::enable_if<
2078 for (
size_t i = 0; i <
size(); ++i)
2082 operator[](i) = tmp;
2094 return v->data() + v->size();
2104 return v->data() + v->size();
2110 return (uint32_t *)v->data();
2115 return ((uint32_t *)v->data()) + v->size();
2120 return (uint32_t *)v->data();
2125 return ((uint32_t *)v->data()) + v->size();
2131 return (uint16_t *)v->data();
2136 return ((uint16_t *)v->data()) + v->size();
2141 return (uint16_t *)v->data();
2146 return ((uint16_t *)v->data()) + v->size();
2152 return (uint8_t *)v->data();
2157 return ((uint8_t *)v->data()) + v->size();
2162 return (uint8_t *)v->data();
2167 return ((uint8_t *)v->data()) + v->size();
bits.hpp contains the sdsl::bits class.
cereal.hpp offers cereal support
A class to encode and decode between comma code and binary code.
A class to encode and decode between Elias- and binary code.
A class to encode and decode between Elias- and binary code.
A class to encode and decode between Fibonacci and binary code.
t_int_vector::difference_type difference_type
const_iterator & operator-=(difference_type i)
t_int_vector::size_type size_type
const_iterator operator-(difference_type i) const
const_iterator operator--(int)
Postfix decrement of the Iterator.
bool operator>(int_vector_const_iterator const &it) const noexcept
int_vector_const_iterator const_iterator
int_vector_const_iterator(int_vector_iterator< t_int_vector > const &it)
bool operator<=(int_vector_const_iterator const &it) const noexcept
const_iterator operator+(difference_type i) const
const_reference operator[](difference_type i) const
const t_int_vector::value_type * pointer
int_vector_const_iterator(int_vector_const_iterator const &)=default
const_iterator & operator+=(difference_type i)
const_reference operator*() const
const_iterator & operator--()
Prefix decrement of the Iterator.
bool operator!=(int_vector_const_iterator const &it) const noexcept
t_int_vector::value_type const_reference
bool operator==(int_vector_const_iterator const &it) const noexcept
int_vector_const_iterator & operator=(int_vector_const_iterator const &)=default
bool operator<(int_vector_const_iterator const &it) const noexcept
bool operator>=(int_vector_const_iterator const &it) const noexcept
int_vector_const_iterator(t_int_vector const *v=nullptr, size_type idx=0)
const_iterator operator++(int)
Postfix increment of the Iterator.
friend int_vector_const_iterator< X >::difference_type operator-(int_vector_const_iterator< X > const &x, int_vector_const_iterator< X > const &y)
const_iterator & operator++()
Prefix increment of the Iterator.
int_vector_iterator_base(t_int_vector const *v=nullptr, size_type idx=0)
int_vector_iterator_base(uint8_t offset, uint8_t len)
typename t_int_vector::difference_type difference_type
typename t_int_vector::value_type value_type
std::random_access_iterator_tag iterator_category
int_vector_iterator iterator
iterator & operator++()
Prefix increment of the Iterator.
reference operator*() const
iterator & operator-=(difference_type i)
bool operator==(int_vector_iterator const &it) const noexcept
bool operator>(int_vector_iterator const &it) const noexcept
bool operator<=(int_vector_iterator const &it) const noexcept
bool operator<(int_vector_iterator const &it) const noexcept
difference_type operator-(int_vector_iterator const &it) const noexcept
bool operator>=(int_vector_iterator const &it) const noexcept
bool operator!=(int_vector_iterator const &it) const noexcept
iterator operator++(int)
Postfix increment of the Iterator.
reference operator[](difference_type i) const
t_int_vector::difference_type difference_type
t_int_vector::size_type size_type
iterator & operator--()
Prefix decrement of the Iterator.
iterator operator+(difference_type i) const
iterator & operator+=(difference_type i)
iterator operator-(difference_type i) const
iterator & operator=(int_vector_iterator< t_int_vector > const &it)
iterator operator--(int)
Postfix decrement of the Iterator.
int_vector_iterator(t_int_vector *v=nullptr, size_type idx=0)
int_vector_iterator(int_vector_iterator< t_int_vector > const &it)
int_vector_reference< t_int_vector > reference
int_vector_reference & operator=(bool x) noexcept
Assignment operator for the proxy class.
int_vector_reference()=delete
Default constructor explicitly deleted.
bool operator<(int_vector_reference const &x) const noexcept
constexpr int_vector_reference(int_vector_reference &&) noexcept=default
constexpr int_vector_reference(int_vector_reference const &) noexcept=default
Copy and move explicitly defaulted.
bool operator==(int_vector_reference const &x) const noexcept
int_vector_reference & operator=(int_vector_reference &&x) noexcept
int_vector_reference & operator=(int_vector_reference const &x) noexcept
A proxy class that acts as a reference to an integer of length len bits in a int_vector.
bool operator==(int_vector_reference const &x) const noexcept
t_int_vector::value_type value_type
bool operator<(int_vector_reference const &x) const noexcept
int_vector_reference & operator=(int_vector_reference &&x) noexcept
int_vector_reference & operator+=(const value_type x) noexcept
Add assign from the proxy object.
int_vector_reference & operator=(value_type x) noexcept
Assignment operator for the proxy class.
int_vector_reference & operator-=(const value_type x) noexcept
Subtract assign from the proxy object.
value_type operator++(int) noexcept
Postfix increment of the proxy object.
int_vector_reference & operator--() noexcept
Prefix decrement of the proxy object.
int_vector_reference()=delete
Default constructor explicitly deleted.
value_type operator--(int) noexcept
Postfix decrement of the proxy object.
int_vector_reference & operator++() noexcept
Prefix increment of the proxy object.
constexpr int_vector_reference(int_vector_reference &&) noexcept=default
constexpr int_vector_reference(int_vector_reference const &) noexcept=default
Copy and move explicitly defaulted.
int_vector_reference & operator=(int_vector_reference const &x) noexcept
A generic vector class for integers of width .
uint64_t const * data() const noexcept
Pointer to the raw data of the int_vector.
iterator end() noexcept
Iterator that points to the element after the last element of int_vector.
void flip()
Flip all bits of bit_vector.
bool operator<=(int_vector const &v) const noexcept
Less or equal operator.
iterator insert(const_iterator it, std::initializer_list< value_type > il)
Insert elements from intializer_list before the element that the iterator is pointing to.
bool operator>(int_vector const &v) const noexcept
Greater operator for two int_vectors.
uint64_t * data() noexcept
Pointer to the raw data of the int_vector.
bool operator!=(int_vector< t_width2 > const &v) const noexcept
Inequality operator for two int_vectors.
rank_support_v< 1, 1 > rank_1_type
size_type capacity() const noexcept
Returns the size of the occupied bits of the int_vector.
std::enable_if<!cereal::traits::is_output_serializable< cereal::BinaryData< int_vector< t_width > >, archive_t >::value, void >::type CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
Serialise (save) via cereal if archive is not binary.
bool empty() const noexcept
Equivalent to size() == 0.
value_type get_int(size_type idx, const uint8_t len=64) const
Get the integer value of the binary string of length len starting at position idx in the int_vector.
value_type const * const_pointer
void assign(size_type size, value_type default_value)
Assign. Resize int_vector to size and fill elements with default_value.
void reserve(size_type capacity)
Reserve storage. If the new capacity is smaller than the current, this method does nothing.
int_vector_trait< t_width >::iterator iterator
void resize(const size_type size, const value_type value)
Resize the int_vector in terms of elements. Only as much space as necessary is allocated.
int_vec_category_trait< t_width >::type index_category
const_iterator end() const noexcept
Const iterator that points to the element after the last element of int_vector.
const_reference back() const noexcept
Returns last element.
int_vector(typename std::enable_if< std::is_base_of< std::input_iterator_tag, typename std::iterator_traits< input_iterator_t >::iterator_category >::value, input_iterator_t >::type first, input_iterator_t last)
Constructor for iterator range.
void swap(int_vector &v) noexcept
Swap method for int_vector.
rank_support_v< 0, 1 > rank_0_type
void bit_resize(const size_type size)
Resize the int_vector in terms of bits. Only as much space as necessary is allocated.
int_vector_size_type size_type
bool operator<(int_vector const &v) const noexcept
Less operator for two int_vectors.
ptrdiff_t difference_type
bool operator==(int_vector< t_width2 > const &v) const noexcept
Equality operator for two int_vectors.
const_reference operator[](size_type const &i) const noexcept
const version of [] operator
select_support_mcl< 0, 1 > select_0_type
void width(uint8_t new_width) noexcept
Sets the width of the integers which are accessed via the [] operator, if t_width equals 0.
int_vector_reference< int_vector > * pointer
int_vector_trait< t_width >::const_reference const_reference
iterator erase(const_iterator it)
Remove element that iterator is pointing to.
int_vector_trait< t_width >::int_width_type int_width_type
size_type write_data(std::ostream &out) const
iterator insert(const_iterator it, size_type n, value_type value)
Insert n copies of an element before the element that the iterator is pointing to.
size_type bit_size() const noexcept
The number of bits in the int_vector.
iterator emplace(const_iterator it, Args &&... args)
Insert an element constructed with std::forward<Args>(args) before the element that the iterator is p...
size_type bit_capacity() const noexcept
Returns the size of the occupied bits of the int_vector.
void clear() noexcept
Clearing the int_vector. Allocated memory will not be released.
reference operator[](size_type const &i) noexcept
non const version of [] operator
int_vector & operator^=(int_vector const &v)
bitwise-xor-update operator
select_support_mcl< 1, 1 > select_1_type
const_iterator begin() const noexcept
Const iterator that points to the first element of the int_vector.
reference back() noexcept
Returns last element.
int_vector & operator=(int_vector &&v)
Move assignment operator.
int_vector_trait< t_width >::const_iterator const_iterator
std::enable_if< std::is_base_of< std::input_iterator_tag, typenamestd::iterator_traits< input_iterator_t >::iterator_category >::value, iterator >::type insert(const_iterator it, input_iterator_t first, input_iterator_t last)
Insert elements from an iterator pair before the element that the iterator it is pointing to.
const_reference at(size_type const &i) const
const version of at() function
void load(std::istream &in)
Load the int_vector for a stream.
bool operator>=(int_vector const &v) const noexcept
Greater of equal operator.
const_iterator cbegin() const noexcept
Const iterator that points to the first element of the int_vector.
int_vector & operator=(int_vector const &v)
Assignment operator.
void shrink_to_fit()
Free unused allocated memory.
uint8_t width() const noexcept
Returns the width of the integers which are accessed via the [] operator.
int_vector_trait< t_width >::reference reference
void emplace_back(Args &&... args)
Insert an element constructed with std::forward<Args>(args) at the end.
void assign(std::initializer_list< value_type > il)
Assign. Resize int_vector and initialize with initializer_list.
size_type size() const noexcept
The number of elements in the int_vector.
int_vector & operator&=(int_vector const &v)
bitwise-and-update operator
static constexpr uint8_t fixed_int_width
iterator insert(const_iterator it, value_type value)
Insert an element before the element that the iterator is pointing to.
void push_back(value_type value)
Insert element at the end.
void assign(input_iterator_t first, input_iterator_t last)
Assign. Resize int_vector and initialize by copying from an iterator range.
float growth_factor
Growth factor for amortized constant time operations.
std::enable_if<!cereal::traits::is_input_serializable< cereal::BinaryData< int_vector< t_width > >, archive_t >::value, void >::type CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
Serialise (load) via cereal if archive is not binary.
std::enable_if< cereal::traits::is_output_serializable< cereal::BinaryData< int_vector< t_width > >, archive_t >::value, void >::type CEREAL_SAVE_FUNCTION_NAME(archive_t &ar) const
Serialise (save) via cereal if archive is binary.
const_iterator cend() const noexcept
Const iterator that points to the element after the last element of int_vector.
int_vector(size_type size=0)
Constructor to fix possible comparison with integeres issue.
int_vector_trait< t_width >::value_type value_type
static size_t read_header(int_vector_size_type &size, int_width_type &int_width, std::istream &in)
Read the size and int_width of a int_vector.
reference at(size_type const &i)
non const version of at() function
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the int_vector to a stream.
int_vector & operator|=(int_vector const &v)
bitwise-or-update equal operator
reference front() noexcept
Returns first element.
int_vector(int_vector &&v)
Move constructor.
std::enable_if< cereal::traits::is_input_serializable< cereal::BinaryData< int_vector< t_width > >, archive_t >::value, void >::type CEREAL_LOAD_FUNCTION_NAME(archive_t &ar)
Serialise (save) via cereal if archive is binary.
static size_type max_size() noexcept
Maximum size of the int_vector.
int_vector(size_type size, value_type default_value, uint8_t int_width=t_width)
Constructor for int_vector.
void resize(const size_type size)
Resize the int_vector in terms of elements.
int_vector(std::initializer_list< value_type > il)
Constructor for initializer_list.
iterator erase(const_iterator first, const_iterator last)
Remove elements in given iterator range.
const_reference front() const noexcept
Returns first element.
static uint64_t write_header(uint64_t size, uint8_t int_width, std::ostream &out)
Write the size and int_width of a int_vector.
bool operator==(int_vector< t_width > const &v) const noexcept
Equality operator for two int_vectors.
int_vector(int_vector const &v)
Copy constructor.
void set_int(size_type idx, value_type x, const uint8_t len=64)
Set the bits from position idx to idx+len-1 to the binary representation of integer x.
void pop_back()
Remove element at the end.
iterator begin() noexcept
Iterator that points to the first element of the int_vector.
static void resize(t_vec &v, const typename t_vec::size_type capacity)
static void clear(t_vec &v)
A rank structure proposed by Sebastiano Vigna.
A class supporting constant time select queries.
static structure_tree_node * add_child(structure_tree_node *v, std::string const &name, std::string const &type)
static void add_size(structure_tree_node *v, uint64_t value)
int_vector_buffer.hpp contains the sdsl::int_vector_buffer class.
io.hpp contains some methods for reading/writing sdsl structures.
memory_management.hpp contains two function for allocating and deallocating memory
void make_nvp(t1 const &, t2 const &)
void make_size_tag(t const &)
t1 binary_data(t1 const &, t2 const &)
const uint64_t SDSL_BLOCK_SIZE
void set_to_value(t_int_vec &v, uint64_t k)
Set all entries of int_vector to value k.
Namespace for the succinct data structure library.
std::ostream & operator<<(std::ostream &os, bp_interval< t_int > const &interval)
int_vector_iterator< t_int_vector > operator+(typename int_vector_iterator< t_int_vector >::difference_type n, int_vector_iterator< t_int_vector > const &it)
void swap(int_vector_reference< t_int_vector > x, int_vector_reference< t_int_vector > y) noexcept
size_t write_member(T const &t, std::ostream &out, sdsl::structure_tree_node *v=nullptr, std::string name="")
void read_member(T &t, std::istream &in)
uint64_t std_size_type_for_int_vector
int_vector< 1 > bit_vector
bit_vector is a specialization of the int_vector.
int_vector_const_iterator< t_int_vector >::difference_type operator-(int_vector_const_iterator< t_int_vector > const &x, int_vector_const_iterator< t_int_vector > const &y)
uint64_t int_vector_size_type
int_vector ::size_type size(range_type const &r)
Size of a range.
Contains declarations and definitions of data structure concepts.
static constexpr void write_int(uint64_t *word, uint64_t x, const uint8_t offset=0, const uint8_t len=64)
Writes value x to an bit position in an array.
static constexpr uint64_t read_int(uint64_t const *word, uint8_t offset=0, const uint8_t len=64)
Reads a value from a bit position in an array.
static constexpr uint64_t lo_set[65]
lo_set[i] is a 64-bit word with the i least significant bits set and the high bits not set.
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
raw_wrapper(int_vector const &_vec)
int_vector< 16 > int_vector_type
static iterator begin(int_vector_type *v) noexcept
static const_iterator end(int_vector_type const *v) noexcept
static iterator end(int_vector_type *v) noexcept
uint16_t const * const_iterator
static void set_width(uint8_t, int_width_type) noexcept
static const_iterator begin(int_vector_type const *v) noexcept
static iterator begin(int_vector_type *v) noexcept
static iterator end(int_vector_type *v) noexcept
static const_iterator begin(int_vector_type const *v) noexcept
static void set_width(uint8_t, int_width_type) noexcept
static const_iterator end(int_vector_type const *v) noexcept
uint32_t const * const_iterator
int_vector< 32 > int_vector_type
static const_iterator end(int_vector_type const *v) noexcept
static iterator begin(int_vector_type *v) noexcept
static iterator end(int_vector_type *v) noexcept
uint64_t const * const_iterator
static const_iterator begin(int_vector_type const *v) noexcept
int_vector< 64 > int_vector_type
static void set_width(uint8_t, int_width_type) noexcept
static const_iterator begin(int_vector_type const *v) noexcept
int_vector< 8 > int_vector_type
static iterator begin(int_vector_type *v) noexcept
static void set_width(uint8_t, int_width_type) noexcept
static const_iterator end(int_vector_type const *v) noexcept
static iterator end(int_vector_type *v) noexcept
uint8_t const * const_iterator
static const_iterator begin(int_vector_type const *v) noexcept
int_vector_const_iterator< int_vector_type > const_iterator
static const_iterator end(int_vector_type const *v) noexcept
int_vector< t_width > int_vector_type
static void set_width(uint8_t new_width, int_width_type &width) noexcept
static iterator begin(int_vector_type *v) noexcept
int_vector_reference< int_vector_type > reference
int_vector_iterator< int_vector_type > iterator
static iterator end(int_vector_type *v) noexcept
structure_tree.hpp contains a helper class which can represent the memory structure of a class.
util.hpp contains some helper methods for int_vector and other stuff like demangle class names.