Skip to content

Commit e79d2b8

Browse files
committed
update docs for this
1 parent 9095a85 commit e79d2b8

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

library/data_structures/seg_tree_uncommon/wavelet_bit_vec.hpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
#pragma once
2+
//! @code
3+
//! vector<bool> a(n);
4+
//! bit_vec bv(a);
5+
//! bv.cnt(r); // a[0] + a[1] + ... + a[r - 1]
6+
//! @endcode
7+
//! @time O(n + q)
8+
//! @space O(n / 64)
29
#define ull uint64_t
310
struct bit_vec {
411
vector<pair<ull, int>> b;
5-
//! @time O(n)
6-
//! @space O(n / 64)
712
bit_vec(const vector<bool>& a): b(sz(a) / 64 + 1) {
813
rep(i, 0, sz(a)) b[i >> 6].first |= ull(a[i])
914
<< (i & 63);
1015
rep(i, 0, sz(b) - 1) b[i + 1].second =
1116
popcount(b[i].first) + b[i].second;
1217
}
13-
//! @returns a[0] + a[1] + ... + a[r - 1]
14-
//! @time O(1)
15-
//! @space O(1)
1618
int cnt(int r) {
1719
auto [x, y] = b[r >> 6];
1820
return y + popcount(x & ((1ULL << (r & 63)) - 1));

0 commit comments

Comments
 (0)