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

Add estimate for space usage of select data structure #444

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
19 changes: 19 additions & 0 deletions include/sdsl/select_support_mcl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ class select_support_mcl : public select_support
select_support_mcl<t_b, t_pat_len>& operator=(const select_support_mcl& ss);
select_support_mcl<t_b, t_pat_len>& operator=(select_support_mcl&&);
void swap(select_support_mcl<t_b, t_pat_len>& ss);
//! Estimate for the number of bits used by this data structure.
size_t bits_used();
};


Expand Down Expand Up @@ -170,6 +172,23 @@ void select_support_mcl<t_b,t_pat_len>::swap(select_support_mcl& ss)
std::swap(m_arg_cnt, ss.m_arg_cnt);
}

template<uint8_t t_b, uint8_t t_pat_len>
size_t select_support_mcl<t_b,t_pat_len>::bits_used()
{
size_t bits = sizeof(*this)*8;
// number of superblocks in the data structure
size_type sb = (m_arg_cnt+4095)>>12;
if (m_arg_cnt) { // if there exists 1-bits to be supported
bits += m_superblock.capacity() + sizeof(m_superblock)*8;
bits += sb*sizeof(m_longsuperblock[0])*8 + sb*sizeof(m_miniblock[0])*8;
for (size_type i=0; i < sb; ++i) {
bits += (m_longsuperblock == nullptr) ? 0 : m_longsuperblock[i].capacity();
bits += (m_miniblock == nullptr) ? 0 : m_miniblock[i].capacity();
}
}
return bits;
}

template<uint8_t t_b, uint8_t t_pat_len>
void select_support_mcl<t_b,t_pat_len>::copy(const select_support_mcl<t_b, t_pat_len>& ss)
{
Expand Down