Skip to content

Commit

Permalink
Allow bvector<>::clear() for read-only frozen vectors
Browse files Browse the repository at this point in the history
  • Loading branch information
tlk00 committed Feb 13, 2022
1 parent 6df8402 commit 6b2c2f9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/bm.h
Original file line number Diff line number Diff line change
Expand Up @@ -1270,13 +1270,13 @@ class bvector
\param free_mem if "true" (default) bvector frees the memory,
otherwise sets blocks to 0.
*/
void clear(bool free_mem = true) { blockman_.set_all_zero(free_mem); }
void clear(bool free_mem = true) BMNOEXCEPT;

/*!
\brief Clears every bit in the bitvector.
\return *this;
*/
bvector<Alloc>& reset() { clear(true); return *this; }
bvector<Alloc>& reset() BMNOEXCEPT { clear(true); return *this; }

/*!
\brief Flips bit n
Expand Down Expand Up @@ -4121,6 +4121,20 @@ void bvector<Alloc>::keep(const size_type* ids, size_type ids_size,

// -----------------------------------------------------------------------

template<class Alloc>
void bvector<Alloc>::clear(bool free_mem) BMNOEXCEPT
{
if (is_ro())
{
BM_ASSERT(free_mem);
blockman_.destroy_arena();
}
else
blockman_.set_all_zero(free_mem);
}

// -----------------------------------------------------------------------

template<class Alloc>
void bvector<Alloc>::clear(const size_type* ids,
size_type ids_size, bm::sort_order so)
Expand Down

0 comments on commit 6b2c2f9

Please sign in to comment.