-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadv_as_view.cpp
More file actions
33 lines (26 loc) · 834 Bytes
/
Copy pathadv_as_view.cpp
File metadata and controls
33 lines (26 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <cds/bit/vector.hpp>
#include <cds/rrr.hpp>
#include <cds/rank/interface.hpp>
#include <cds/select/interface.hpp>
#include <cstdint>
#include <iostream>
using u64 = std::uint64_t;
void call_rank(cds::rank_interface* ri) {
std::cout << "rank1(5000) = " << ri->rank1(5000) << '\n';
}
void call_select(cds::select_interface* si) {
std::cout << "select1(10) = " << si->select1(10) << '\n';
std::cout << "select0(10) = " << si->select0(10) << '\n';
}
int main() {
cds::bit_vector<u64, cds::pack_endian::lsb> bv;
bv.reserve(10000);
for (int i = 0; i < 10000; ++i)
bv.push_back(i % 5 == 0);
cds::rrr<> backend(bv);
auto rnk = cds::rank_adapter(backend.as_view());
auto sel = cds::select_adapter(backend.as_view());
call_rank(&rnk);
call_select(&sel);
return 0;
}