//! Swap operator void swap(wt_int_rlmn& wt) { if (this != &wt) { std::swap(m_size, wt.m_size); m_bl.swap(wt.m_bl); m_bf.swap(wt.m_bf); m_wt.swap(wt.m_wt); m_bl_rank.swap(wt.m_bl_rank); m_bl_rank.set_vector(&m_bl); wt.m_bl_rank.set_vector(&(wt.m_bl)); m_bf_rank.swap(wt.m_bf_rank); m_bf_rank.set_vector(&m_bf); wt.m_bf_rank.set_vector(&(wt.m_bf)); m_bl_select.swap(wt.m_bl_select); m_bl_select.set_vector(&m_bl); wt.m_bl_select.set_vector(&(wt.m_bl)); m_bf_select.swap(wt.m_bf_select); m_bf_select.set_vector(&m_bf); wt.m_bf_select.set_vector(&(wt.m_bf)); m_C.swap(wt.m_C); m_C_bf_rank.swap(wt.m_C_bf_rank); } }
/*! * \param i The ith occurrence. \f$i\in [1..rank(size(),c)]\f$. * \param c The symbol c. * \par Time complexity * \f$ \Order{H_0} \f$ on average, where \f$ H_0 \f$ is the zero order * entropy of the sequence */ size_type select(size_type i, value_type c)const { assert(i > 0); assert(i <= rank(size(), c)); size_type c_runs = m_bf_rank(m_C[c]+i) - m_C_bf_rank[c]; size_type offset = m_C[c] + i - 1 - m_bf_select(c_runs + m_C_bf_rank[c]); return m_bl_select(m_wt.select(c_runs, c)+1) + offset; };
//! Swap operation void swap(matching_index& idx) { if (this != &idx) { m_text.swap(idx.m_text); m_wt.swap(idx.m_wt); } }
//! Serializes the data structure into the given ostream size_type serialize(std::ostream& out, sdsl::structure_tree_node* v=nullptr, std::string name="")const { sdsl::structure_tree_node* child = sdsl::structure_tree::add_child(v, name, sdsl::util::class_name(*this)); size_type written_bytes = 0; written_bytes += m_text.serialize(out, child, "text"); written_bytes += m_wt.serialize(out, child, "wt"); sdsl::structure_tree::add_size(child, written_bytes); return written_bytes; }
//! Loads the data structure from the given istream. void load(std::istream& in) { read_member(m_size, in); m_bl.load(in); m_bf.load(in); m_wt.load(in); m_bl_rank.load(in, &m_bl); m_bf_rank.load(in, &m_bf); m_bl_select.load(in, &m_bl); m_bf_select.load(in, &m_bf); m_C.load(in); m_C_bf_rank.load(in); }
/*! * \param i The exclusive index of the prefix range [0..i-1], so \f$i\in[0..size()]\f$. * \param c The symbol to count the occurrences in the prefix. * \return The number of occurrences of symbol c in the prefix [0..i-1] of the supported vector. * \par Time complexity * \f$ \Order{H_0} \f$ on average, where \f$ H_0 \f$ is the zero order entropy of * the sequence */ size_type rank(size_type i, value_type c)const { assert(i <= size()); if (i == 0) return 0; size_type wt_ex_pos = m_bl_rank(i); size_type c_runs = m_wt.rank(wt_ex_pos, c); if (c_runs == 0) return 0; if (m_wt[wt_ex_pos-1] == c) { size_type c_run_begin = m_bl_select(wt_ex_pos); return m_bf_select(m_C_bf_rank[c] + c_runs) - m_C[c] + i - c_run_begin; } else { return m_bf_select(m_C_bf_rank[c] + c_runs + 1) - m_C[c]; } };
//! Serializes the data structure into the given ostream size_type serialize(std::ostream& out, structure_tree_node* v=nullptr, std::string name="")const { structure_tree_node* child = structure_tree::add_child(v, name, util::class_name(*this)); size_type written_bytes = 0; written_bytes += write_member(m_size, out, child, "size"); written_bytes += m_bl.serialize(out, child, "bl"); written_bytes += m_bf.serialize(out, child, "bf"); written_bytes += m_wt.serialize(out, child, "wt"); written_bytes += m_bl_rank.serialize(out, child, "bl_rank"); written_bytes += m_bf_rank.serialize(out, child, "bf_rank"); written_bytes += m_bl_select.serialize(out, child, "bl_select"); written_bytes += m_bf_select.serialize(out, child, "bf_select"); written_bytes += m_C.serialize(out, child, "C"); written_bytes += m_C_bf_rank.serialize(out, child, "C_bf_rank"); structure_tree::add_size(child, written_bytes); return written_bytes; }
/*! * \param i The index of the symbol. * \param c Reference that will contain the symbol at position i after the execution of the method. * \return The number of occurrences of symbol wt[i] in the prefix [0..i-1] * \par Time complexity * \f$ \Order{H_0} \f$ */ size_type inverse_select(size_type i, value_type& c)const { assert(i < size()); if (i == 0) { c = m_wt[0]; return 0; } size_type wt_ex_pos = m_bl_rank(i+1); size_type c_runs = m_wt.inverse_select(wt_ex_pos-1, c)+1; if (c_runs == 0) return 0; if (m_wt[wt_ex_pos-1] == c) { size_type c_run_begin = m_bl_select(wt_ex_pos); return m_bf_select(m_C_bf_rank[c] + c_runs) - m_C[c] + i - c_run_begin; } else { return m_bf_select(m_C_bf_rank[c] + c_runs + 1) - m_C[c]; } }
//! Loads the data structure from the given istream. void load(std::istream& in) { m_text.load(in); m_wt.load(in); }