Skip to content

Commit

Permalink
fixed assignment operators in int_vector iterators
Browse files Browse the repository at this point in the history
and other cleanups
  • Loading branch information
karasikov committed Jan 20, 2021
1 parent 6ac4212 commit ce1347f
Showing 1 changed file with 7 additions and 34 deletions.
41 changes: 7 additions & 34 deletions include/sdsl/int_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -870,14 +870,6 @@ class int_vector_iterator : public int_vector_iterator_base<t_int_vector>
int_vector_iterator_base<t_int_vector>(v, idx),
m_word((v != nullptr) ? v->m_data + (idx>>6) : nullptr) {}


int_vector_iterator(const int_vector_iterator<t_int_vector>& it) :
int_vector_iterator_base<t_int_vector>(it), m_word(it.m_word)
{
m_offset = it.m_offset;
m_len = it.m_len;
}

reference operator*() const
{
return reference(m_word, m_offset, m_len);
Expand Down Expand Up @@ -947,16 +939,6 @@ class int_vector_iterator : public int_vector_iterator_base<t_int_vector>
return *this;
}

iterator& operator=(const int_vector_iterator<t_int_vector>& it)
{
if (this != &it) {
m_word = it.m_word;
m_offset = it.m_offset;
m_len = it.m_len;
}
return *this;
}

iterator operator+(difference_type i) const
{
iterator it = *this;
Expand Down Expand Up @@ -1038,8 +1020,6 @@ class int_vector_const_iterator : public int_vector_iterator_base<t_int_vector>
template<class X>
friend typename int_vector_const_iterator<X>::difference_type
operator-(const int_vector_const_iterator<X>& x, const int_vector_const_iterator<X>& y);
friend class int_vector_iterator<t_int_vector>;
friend class int_vector_iterator_base<t_int_vector>;

private:

Expand All @@ -1054,27 +1034,20 @@ class int_vector_const_iterator : public int_vector_iterator_base<t_int_vector>
int_vector_iterator_base<t_int_vector>(v, idx),
m_word((v != nullptr) ? v->m_data + (idx>>6) : nullptr) {}

int_vector_const_iterator(const int_vector_const_iterator& it):
int_vector_iterator_base<t_int_vector>(it), m_word(it.m_word)
{
m_offset = it.m_offset;
m_len = it.m_len;
}

int_vector_const_iterator(const int_vector_iterator<t_int_vector>& it):
m_word(it.m_word)
int_vector_iterator_base<t_int_vector>(it), m_word(it.m_word) {}

int_vector_const_iterator& operator=(const int_vector_iterator<t_int_vector>& it)
{
m_word = it.m_word;
m_offset = it.m_offset;
m_len = it.m_len;
m_len = it.m_len;
return *this;
}

const_reference operator*() const
{
if (m_offset+m_len <= 64) {
return ((*m_word)>>m_offset)&bits::lo_set[m_len];
}
return ((*m_word)>>m_offset) |
((*(m_word+1) & bits::lo_set[(m_offset+m_len)&0x3F])<<(64-m_offset));
return bits::read_int(m_word, m_offset, m_len);
}

//! Prefix increment of the Iterator
Expand Down

0 comments on commit ce1347f

Please sign in to comment.