8#ifndef INCLUDED_SDSL_INT_VECTOR
9#define INCLUDED_SDSL_INT_VECTOR
17#include <initializer_list>
46template <u
int8_t t_w
idth = 0>
49template <
class int_vector_type>
55template <
class t_
int_vector>
58template <
class t_
int_vector>
61template <
class t_
int_vector>
64template <
class t_
int_vector>
67template <u
int8_t t_w
idth, std::ios_base::openmode t_mode>
70template <u
int8_t b, u
int8_t t_patter_len>
77template <u
int8_t t_bit_pattern, u
int8_t t_pattern_len>
88template <u
int8_t t_w
idth>
92template <u
int8_t t_w
idth>
104template <u
int8_t t_w
idth>
122 if constexpr (t_width == 0) width = new_width ? std::min(new_width, uint8_t{ 64u }) : 64u;
214template <u
int8_t t_w
idth>
218 static_assert(t_width <= 64,
"int_vector: width of must be at most 64bits.");
241 template <u
int8_t, std::ios_base::openmode>
243 template <
typename T>
245 template <
typename T>
247 template <
typename T>
269 if constexpr (t_width != 0)
272 if (
bit_size > m_capacity || m_data ==
nullptr)
275 size_type new_capacity = std::max<size_type>(m_capacity, 64u);
285 if (
bit_size > m_capacity || m_data ==
nullptr)
288 size_type new_capacity = std::max<size_type>(m_capacity, 64u);
298 size_type bit_data_size()
const {
return (m_size + 63) >> 6; }
325 template <
typename input_iterator_t>
326 int_vector(
typename std::enable_if<std::is_base_of<std::input_iterator_tag,
327 typename std::iterator_traits<input_iterator_t>::iterator_category>::
329 input_iterator_t>::type first,
330 input_iterator_t last)
339 void clear() noexcept { m_size = 0; }
347 std::copy(it_nonconst + 1,
end(), it_nonconst);
360 std::copy(last_nonconst,
end(), first_nonconst);
362 return first_nonconst;
369 template <
class... Args>
389 amortized_resize(
size() + n);
391 std::copy_backward(it_new,
end() - n,
end());
392 std::fill_n(it_new, n, value);
402 return insert(it, il.begin(), il.end());
410 template <
typename input_iterator_t>
411 typename std::enable_if<std::is_base_of<std::input_iterator_tag,
412 typename std::iterator_traits<input_iterator_t>::iterator_category>::value,
417 amortized_resize(
size() + last - first);
419 std::copy_backward(it_new,
end() - (last - first),
end());
420 std::copy(first, last, it_new);
439 template <
class... Args>
450 amortized_resize(
size() + 1);
451 *(
end() - 1) = value;
472 bit_resize(
size * m_width);
479 void assign(std::initializer_list<value_type> il)
481 bit_resize(il.size() * m_width);
483 for (
auto x : il) { (*this)[idx++] = x; }
490 template <
typename input_iterator_t>
491 void assign(input_iterator_t first, input_iterator_t last)
493 assert(first <= last);
494 bit_resize((last - first) * m_width);
496 while (first < last) { (*this)[idx++] = *(first++); }
500 bool empty() const noexcept {
return 0 == m_size; }
566 const uint64_t *
data() const noexcept {
return m_data; }
571 uint64_t *
data() noexcept {
return m_data; }
595 uint8_t
width() const noexcept {
return m_width; }
622 template <
typename archive_t>
623 inline typename std::enable_if<!cereal::traits::is_output_serializable<cereal::BinaryData<int_vector<t_width>>,
629 template <
typename archive_t>
630 inline typename std::enable_if<cereal::traits::is_output_serializable<cereal::BinaryData<int_vector<t_width>>,
636 template <
typename archive_t>
637 inline typename std::enable_if<!cereal::traits::is_input_serializable<cereal::BinaryData<int_vector<t_width>>,
643 template <
typename archive_t>
644 inline typename std::enable_if<cereal::traits::is_input_serializable<cereal::BinaryData<int_vector<t_width>>,
688 if (
bit_size() != v.bit_size())
return false;
689 if (
empty())
return true;
690 const uint64_t * data1 = v.data();
691 const uint64_t * data2 =
data();
692 for (
size_type i = 0; i < bit_data_size() - 1; ++i)
694 if (*(data1++) != *(data2++))
return false;
696 uint8_t l = 64 - ((bit_data_size() << 6) - m_size);
707 template <
class container>
710 return std::equal(lhs.begin(), lhs.end(), rhs.begin());
720 template <u
int8_t t_w
idth2>
723 return !(*
this == v);
781 static_assert(1 == t_width,
"int_vector: flip() is available only for bit_vector.");
784 for (uint64_t i = 0; i < bit_data_size(); ++i) { m_data[i] = ~m_data[i]; }
791 uint64_t width_and_size = 0;
794 uint8_t read_int_width = (uint8_t)(width_and_size >> 56);
795 if (t_width == 0) { int_width = read_int_width; }
796 if (t_width > 0 and t_width != read_int_width)
798 std::cerr <<
"Warning: Width of int_vector<" << (size_t)t_width <<
">";
799 std::cerr <<
" was specified as " << (
size_type)read_int_width << std::endl;
800 std::cerr <<
"Length is " <<
size <<
" bits" << std::endl;
802 return sizeof(width_and_size);
810 if (t_width != int_width)
812 std::cout <<
"Warning: writing width=" << (
size_type)int_width <<
" != fixed " << (
size_type)t_width
816 uint64_t width_and_size = (((uint64_t)int_width) << 56) |
size;
833 return written_bytes;
843template <
class t_
int_vector>
850 typename t_int_vector::value_type *
const m_word;
851 const uint8_t m_offset;
902 value_type val = (
typename t_int_vector::value_type) *
this;
945template <
class t_
int_vector>
955template <
class t_
int_vector>
966template <
class t_
int_vector>
986 uint64_t *
const m_word;
1002 , m_mask(1ULL << offset){};
1018 operator bool() const noexcept {
return !!(*m_word & m_mask); }
1055template <
class t_
int_vector>
1079 ,
m_len(v == nullptr ? 0 : v->m_width)
1083template <
class t_
int_vector>
1100 typename t_int_vector::value_type * m_word;
1105 , m_word((v != nullptr) ? v->m_data + (idx >> 6) : nullptr)
1160 if (i < 0)
return *
this -= (-i);
1163 if ((
m_offset += (t & 0x3F)) & ~0x3F)
1173 if (i < 0)
return *
this += (-i);
1176 if ((
m_offset -= (t & 0x3F)) & ~0x3F)
1211 return it.m_word == m_word && it.m_offset ==
m_offset;
1218 if (m_word == it.m_word)
return m_offset < it.m_offset;
1219 return m_word < it.m_word;
1224 if (m_word == it.m_word)
return m_offset > it.m_offset;
1225 return m_word > it.m_word;
1233 return (((m_word - it.m_word) << 6) +
m_offset - it.m_offset) /
m_len;
1242template <
class t_
int_vector>
1249template <
class t_
int_vector>
1254 typedef const typename t_int_vector::value_type *
pointer;
1269 const typename t_int_vector::value_type * m_word;
1274 , m_word((v != nullptr) ? v->m_data + (idx >> 6) : nullptr)
1336 if (i < 0)
return *
this -= (-i);
1339 if ((
m_offset += (t & 0x3F)) & ~0x3F)
1349 if (i < 0)
return *
this += (-i);
1352 if ((
m_offset -= (t & 0x3F)) & ~0x3F)
1376 return it.m_word == m_word && it.m_offset ==
m_offset;
1383 if (m_word == it.m_word)
return m_offset < it.m_offset;
1384 return m_word < it.m_word;
1389 if (m_word == it.m_word)
return m_offset > it.m_offset;
1390 return m_word > it.m_word;
1398template <
class t_
int_vector>
1406template <
class t_
int_vector>
1414template <
class t_bv>
1415inline typename std::enable_if<std::is_same<typename t_bv::index_category, bv_tag>::value, std::ostream &>::type
1416operator<<(std::ostream & os,
const t_bv & bv)
1418 for (
auto b : bv) { os << b; }
1424template <u
int8_t t_w
idth>
1435template <u
int8_t t_w
idth>
1438 , m_capacity(v.m_capacity)
1440 , m_width(v.m_width)
1447template <u
int8_t t_w
idth>
1452 , m_width(v.m_width)
1458 if (memcpy(m_data, v.
data(), bit_data_size() << 3) ==
nullptr)
1460 throw std::bad_alloc();
1465template <u
int8_t t_w
idth>
1471 *
this = std::move(tmp);
1476template <u
int8_t t_w
idth>
1484 m_width = v.m_width;
1485 m_capacity = v.m_capacity;
1494template <u
int8_t t_w
idth>
1501template <u
int8_t t_w
idth>
1507template <u
int8_t t_w
idth>
1514template <u
int8_t t_w
idth>
1517 size_type old_size = m_size;
1519 auto it = begin() + old_size / m_width;
1523template <u
int8_t t_w
idth>
1527 if (idx + len > m_size)
1529 throw std::out_of_range(
"OUT_OF_RANGE_ERROR: int_vector::get_int(size_type, uint8_t); idx+len > size()!");
1531 if (len > 64) {
throw std::out_of_range(
"OUT_OF_RANGE_ERROR: int_vector::get_int(size_type, uint8_t); len>64!"); }
1536template <u
int8_t t_w
idth>
1540 if (idx + len > m_size)
1542 throw std::out_of_range(
"OUT_OF_RANGE_ERROR: int_vector::set_int(size_type, uint8_t); idx+len > size()!");
1544 if (len > 64) {
throw std::out_of_range(
"OUT_OF_RANGE_ERROR: int_vector::set_int(size_type, uint8_t); len>64!"); }
1549template <u
int8_t t_w
idth>
1552 return m_size / t_width;
1594 return m_size / m_width;
1597template <u
int8_t t_w
idth>
1600 return m_capacity / t_width;
1607 return m_capacity >> 6;
1614 return m_capacity >> 5;
1621 return m_capacity >> 4;
1628 return m_capacity >> 3;
1642 return m_capacity / m_width;
1645template <u
int8_t t_w
idth>
1648 assert(idx < this->
size());
1650 return reference(this->m_data + (i >> 6), i & 0x3F, m_width);
1657 assert(idx < this->
size());
1658 return *(this->m_data + idx);
1665 assert(idx < this->
size());
1666 return *(((uint32_t *)(this->m_data)) + idx);
1673 assert(idx < this->
size());
1674 return *(((uint16_t *)(this->m_data)) + idx);
1681 assert(idx < this->
size());
1682 return *(((uint8_t *)(this->m_data)) + idx);
1685template <u
int8_t t_w
idth>
1688 assert(idx < this->
size());
1689 return get_int(idx * t_width, t_width);
1695 assert(idx < this->
size());
1696 return get_int(idx * m_width, m_width);
1702 assert(idx < this->
size());
1703 return *(this->m_data + idx);
1709 assert(idx < this->
size());
1710 return *(((uint32_t *)this->m_data) + idx);
1716 assert(idx < this->
size());
1717 return *(((uint16_t *)this->m_data) + idx);
1723 assert(idx < this->
size());
1724 return *(((uint8_t *)this->m_data) + idx);
1730 assert(idx < this->
size());
1731 return ((*(m_data + (idx >> 6))) >> (idx & 0x3F)) & 1;
1734template <u
int8_t t_w
idth>
1738 if (min_size > v.size()) min_size = v.size();
1739 for (
auto it = begin(), end = begin() + min_size, it_v = v.begin(); it != end; ++it, ++it_v)
1749template <u
int8_t t_w
idth>
1753 if (min_size > v.size()) min_size = v.size();
1754 for (
auto it = begin(), end = begin() + min_size, it_v = v.begin(); it != end; ++it, ++it_v)
1764template <u
int8_t t_w
idth>
1767 return *
this == v or *
this < v;
1770template <u
int8_t t_w
idth>
1773 return *
this == v or *
this > v;
1776template <u
int8_t t_w
idth>
1779 assert(v.
bit_size() == bit_size());
1780 for (uint64_t i = 0; i < bit_data_size(); ++i) m_data[i] &= v.m_data[i];
1784template <u
int8_t t_w
idth>
1787 assert(bit_size() == v.
bit_size());
1788 for (uint64_t i = 0; i < bit_data_size(); ++i) m_data[i] |= v.m_data[i];
1792template <u
int8_t t_w
idth>
1795 assert(bit_size() == v.
bit_size());
1796 for (uint64_t i = 0; i < bit_data_size(); ++i) m_data[i] ^= v.m_data[i];
1800template <u
int8_t t_w
idth>
1804 uint64_t * p = m_data;
1813 out.write((
char *)p, (bit_data_size() - idx) *
sizeof(uint64_t));
1814 written_bytes += (bit_data_size() - idx) *
sizeof(uint64_t);
1815 return written_bytes;
1818template <u
int8_t t_w
idth>
1821 std::string name)
const
1825 written_bytes += write_data(out);
1827 return written_bytes;
1830template <u
int8_t t_w
idth>
1837 uint64_t * p = m_data;
1845 in.read((
char *)p, (bit_data_size() - idx) *
sizeof(uint64_t));
1848template <u
int8_t t_w
idth>
1849template <
typename archive_t>
1850inline typename std::enable_if<cereal::traits::is_output_serializable<cereal::BinaryData<int_vector<t_width>>,
1861template <u
int8_t t_w
idth>
1862template <
typename archive_t>
1863inline typename std::enable_if<!cereal::traits::is_output_serializable<cereal::BinaryData<int_vector<t_width>>,
1871 for (value_type
const & v : *
this) ar(v);
1874template <u
int8_t t_w
idth>
1875template <
typename archive_t>
1876inline typename std::enable_if<cereal::traits::is_input_serializable<cereal::BinaryData<int_vector<t_width>>,
1888template <u
int8_t t_w
idth>
1889template <
typename archive_t>
1890inline typename std::enable_if<!cereal::traits::is_input_serializable<cereal::BinaryData<int_vector<t_width>>,
1901 for (
size_t i = 0; i <
size(); ++i)
1905 operator[](i) = tmp;
1917 return v->data() + v->size();
1927 return v->data() + v->size();
1933 return (uint32_t *)v->data();
1938 return ((uint32_t *)v->data()) + v->size();
1943 return (uint32_t *)v->data();
1948 return ((uint32_t *)v->data()) + v->size();
1954 return (uint16_t *)v->data();
1959 return ((uint16_t *)v->data()) + v->size();
1964 return (uint16_t *)v->data();
1969 return ((uint16_t *)v->data()) + v->size();
1975 return (uint8_t *)v->data();
1980 return ((uint8_t *)v->data()) + v->size();
1985 return (uint8_t *)v->data();
1990 return ((uint8_t *)v->data()) + v->size();
bits.hpp contains the sdsl::bits class.
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!=(const int_vector_const_iterator &it) const noexcept
int_vector_const_iterator const_iterator
const_iterator operator+(difference_type i) const
int_vector_const_iterator(const int_vector_iterator< t_int_vector > &it)
const_reference operator[](difference_type i) const
const t_int_vector::value_type * pointer
bool operator>(const int_vector_const_iterator &it) const noexcept
const_iterator & operator+=(difference_type i)
bool operator>=(const int_vector_const_iterator &it) const noexcept
bool operator<=(const int_vector_const_iterator &it) const noexcept
int_vector_const_iterator(const int_vector_const_iterator &)=default
const_reference operator*() const
const_iterator & operator--()
Prefix decrement of the Iterator.
friend int_vector_const_iterator< X >::difference_type operator-(const int_vector_const_iterator< X > &x, const int_vector_const_iterator< X > &y)
t_int_vector::value_type const_reference
bool operator<(const int_vector_const_iterator &it) const noexcept
int_vector_const_iterator(const t_int_vector *v=nullptr, size_type idx=0)
bool operator==(const int_vector_const_iterator &it) const noexcept
int_vector_const_iterator & operator=(const int_vector_const_iterator &)=default
const_iterator operator++(int)
Postfix increment of the Iterator.
const_iterator & operator++()
Prefix increment of the Iterator.
int_vector_iterator_base(const t_int_vector *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)
iterator operator++(int)
Postfix increment of the Iterator.
bool operator<(const int_vector_iterator &it) const noexcept
bool operator==(const int_vector_iterator &it) const noexcept
reference operator[](difference_type i) const
int_vector_iterator(const int_vector_iterator< t_int_vector > &it)
t_int_vector::difference_type difference_type
bool operator!=(const int_vector_iterator &it) const noexcept
bool operator<=(const int_vector_iterator &it) const noexcept
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
bool operator>=(const int_vector_iterator &it) const noexcept
iterator operator--(int)
Postfix decrement of the Iterator.
int_vector_iterator(t_int_vector *v=nullptr, size_type idx=0)
difference_type operator-(const int_vector_iterator &it) const noexcept
iterator & operator=(const int_vector_iterator< t_int_vector > &it)
bool operator>(const int_vector_iterator &it) const noexcept
int_vector_reference< t_int_vector > reference
bool operator<(const int_vector_reference &x) const noexcept
int_vector_reference & operator=(const int_vector_reference &x) noexcept
int_vector_reference & operator=(bool x) noexcept
Assignment operator for the proxy class.
int_vector_reference()=delete
Default constructor explicitly deleted.
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 &&x) noexcept
bool operator==(const int_vector_reference &x) const noexcept
A proxy class that acts as a reference to an integer of length len bits in a int_vector.
t_int_vector::value_type value_type
bool operator<(const int_vector_reference &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.
int_vector_reference & operator=(const int_vector_reference &x) noexcept
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.
bool operator==(const int_vector_reference &x) const noexcept
A generic vector class for integers of width .
iterator end() noexcept
Iterator that points to the element after the last element of int_vector.
void flip()
Flip all bits of bit_vector.
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.
uint64_t * data() noexcept
Pointer to the raw data of the int_vector.
reference operator[](const size_type &i) noexcept
non const version of [] operator
rank_support_v< 1, 1 > rank_1_type
int_vector(const int_vector &v)
Copy constructor.
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.
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 value_type * const_pointer
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
ptrdiff_t difference_type
bool operator>(const int_vector &v) const noexcept
Greater operator for two int_vectors.
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.
bool operator>=(const int_vector &v) const noexcept
Greater of equal operator.
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
reference at(const size_type &i)
non const version of at() function
friend bool operator==(const int_vector< t_width > &lhs, const container &rhs) noexcept
Equality operator for an arbitrary container.
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.
int_vector & operator|=(const int_vector &v)
bitwise-or-update equal operator
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...
int_vector & operator=(const int_vector &v)
Assignment operator.
size_type bit_capacity() const noexcept
Returns the size of the occupied bits of the int_vector.
bool operator!=(const int_vector< t_width2 > &v) const noexcept
Inequality operator for two int_vectors.
void clear() noexcept
Clearing the int_vector. Allocated memory will not be released.
bool operator<(const int_vector &v) const noexcept
Less operator for two int_vectors.
int_vector & operator&=(const int_vector &v)
bitwise-and-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.
void load(std::istream &in)
Load the int_vector for a stream.
bool operator<=(const int_vector &v) const noexcept
Less or equal operator.
const_iterator cbegin() const noexcept
Const iterator that points to the first element of the int_vector.
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.
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.
const_reference at(const size_type &i) const
const version of at() function
int_vector & operator^=(const int_vector &v)
bitwise-xor-update operator
const_reference operator[](const size_type &i) const noexcept
const version of [] operator
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.
const uint64_t * data() const noexcept
Pointer to the raw data of the int_vector.
bool operator==(const int_vector< t_width > &v) const noexcept
Equality operator for two int_vectors.
size_type serialize(std::ostream &out, structure_tree_node *v=nullptr, std::string name="") const
Serializes the int_vector to a stream.
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.
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.
The base class of classes supporting rank_queries for a sdsl::bit_vector in constant time.
A class supporting constant time select queries.
The base class of classes supporting select queries for a sdsl::bit_vector in constant time.
static structure_tree_node * add_child(structure_tree_node *v, const std::string &name, const std::string &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.
int_vector_iterator< t_int_vector > operator+(typename int_vector_iterator< t_int_vector >::difference_type n, const int_vector_iterator< t_int_vector > &it)
void swap(int_vector_reference< t_int_vector > x, int_vector_reference< t_int_vector > y) noexcept
int_vector_const_iterator< t_int_vector >::difference_type operator-(const int_vector_const_iterator< t_int_vector > &x, const int_vector_const_iterator< t_int_vector > &y)
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)
uint64_t std_size_type_for_int_vector
int_vector< 1 > bit_vector
bit_vector is a specialization of the int_vector.
uint64_t int_vector_size_type
int_vector ::size_type size(const range_type &r)
Size of a range.
std::ostream & operator<<(std::ostream &os, const bp_interval< t_int > &interval)
sfstream.hpp contains a two stream class which can be used to read/write from/to files or strings.
static constexpr uint64_t read_int(const uint64_t *word, uint8_t offset=0, const uint8_t len=64)
Reads a value from a bit position in an array.
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 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(const int_vector &_vec)
int_vector< 16 > int_vector_type
static iterator begin(int_vector_type *v) noexcept
static iterator end(int_vector_type *v) noexcept
static const_iterator begin(const int_vector_type *v) noexcept
static void set_width(uint8_t, int_width_type) noexcept
static const_iterator end(const int_vector_type *v) noexcept
const uint16_t * const_iterator
const uint32_t * const_iterator
static iterator begin(int_vector_type *v) noexcept
static iterator end(int_vector_type *v) noexcept
static void set_width(uint8_t, int_width_type) noexcept
static const_iterator end(const int_vector_type *v) noexcept
static const_iterator begin(const int_vector_type *v) noexcept
int_vector< 32 > int_vector_type
const uint64_t * const_iterator
static const_iterator begin(const int_vector_type *v) noexcept
static iterator begin(int_vector_type *v) noexcept
static iterator end(int_vector_type *v) noexcept
static const_iterator end(const int_vector_type *v) noexcept
int_vector< 64 > int_vector_type
static void set_width(uint8_t, int_width_type) noexcept
static const_iterator begin(const int_vector_type *v) noexcept
int_vector< 8 > int_vector_type
const uint8_t * const_iterator
static iterator begin(int_vector_type *v) noexcept
static void set_width(uint8_t, int_width_type) noexcept
static const_iterator end(const int_vector_type *v) noexcept
static iterator end(int_vector_type *v) noexcept
int_vector_const_iterator< int_vector_type > const_iterator
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
static const_iterator end(const int_vector_type *v) noexcept
int_vector_iterator< int_vector_type > iterator
static const_iterator begin(const int_vector_type *v) noexcept
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.