/*! * \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]; } };