Returns the rank of the i-th symbol among symbols with the same value.
| 58 | // Returns the rank of the i-th symbol among symbols with the same |
| 59 | // value. |
| 60 | size_t Rank(size_t i) const |
| 61 | { |
| 62 | ASSERT_LESS(i, Size(), ()); |
| 63 | if (i == 0) |
| 64 | return 0; |
| 65 | |
| 66 | --i; |
| 67 | auto it = std::upper_bound(m_starts.begin(), m_starts.end(), i); |
| 68 | if (it == m_starts.begin()) |
| 69 | return i; |
| 70 | --it; |
| 71 | return i - *it; |
| 72 | } |
| 73 | |
| 74 | private: |
| 75 | size_t const m_n; |