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 #120

Merged
merged 2 commits into from
Sep 11, 2023
Merged
Changes from 1 commit
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 @@ -30,6 +30,7 @@ class int_vector_buffer

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 @@ -493,7 +494,7 @@ class int_vector_buffer
class iterator
{
private:
int_vector_buffer<t_width> & m_ivb;
int_vector_buffer<t_width> * m_ivb;
eseiler marked this conversation as resolved.
Show resolved Hide resolved
uint64_t m_idx = 0;

public:
Expand All @@ -504,7 +505,7 @@ class int_vector_buffer
using reference = sdsl::int_vector_buffer<t_width>::reference;

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 @@ -535,7 +536,7 @@ class int_vector_buffer

reference operator*() const
{
return m_ivb[m_idx];
return (*m_ivb)[m_idx];
eseiler marked this conversation as resolved.
Show resolved Hide resolved
}

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

bool operator==(iterator const & 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!=(iterator const & it) const
Expand Down