Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use pointer to the container for int_vector_buffer iterator #437

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions include/sdsl/int_vector_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class int_vector_buffer
class iterator;
typedef typename int_vector<t_width>::difference_type difference_type;
typedef typename int_vector<t_width>::value_type value_type;
typedef typename int_vector<t_width>::size_type size_type;

private:
static_assert(t_width <= 64 , "int_vector_buffer: width must be at most 64 bits.");
Expand Down Expand Up @@ -489,12 +490,12 @@ class int_vector_buffer
class iterator: public std::iterator<std::random_access_iterator_tag, value_type, difference_type, value_type*, reference>
{
private:
int_vector_buffer<t_width>& m_ivb;
int_vector_buffer<t_width>* m_ivb;
uint64_t m_idx = 0;
public:

iterator() = delete;
iterator(int_vector_buffer<t_width>& ivb, uint64_t idx=0) : m_ivb(ivb), m_idx(idx) {}
iterator(int_vector_buffer<t_width>& ivb, uint64_t idx=0) : m_ivb(&ivb), m_idx(idx) {}

iterator& operator++()
{
Expand Down Expand Up @@ -524,7 +525,7 @@ class int_vector_buffer

reference operator*()const
{
return m_ivb[m_idx];
return (*m_ivb)[m_idx];
}

iterator& operator+=(difference_type i)
Expand Down Expand Up @@ -557,7 +558,7 @@ class int_vector_buffer

bool operator==(const iterator& it) const
{
return &m_ivb == &(it.m_ivb) and m_idx == it.m_idx;
return m_ivb == it.m_ivb and m_idx == it.m_idx;
}

bool operator!=(const iterator& it) const
Expand Down