Skip to content
Snippets Groups Projects
Commit b5f06d3a authored by Salson Mikael's avatar Salson Mikael
Browse files

refactor Coverind constructors

Split constructor in methods that are (will) reused elsewhere
parent be8ccc33
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,10 @@ public:
size_t size_in_bytes() const;
void save(const std::string) const;
private:
void create_rank_select();
void build_from_bitvectors(const bit_vector &start_bv, const bit_vector &end_bv);
};
bit_vector create_bitvector_from_file(const std::string filename);
......@@ -74,9 +78,22 @@ bit_vector create_bitvector_from_file(const std::string filename);
template <class bv>
Coverind<bv>::Coverind(const std::string start_file, const std::string end_file) {
start = bv(create_bitvector_from_file(start_file));
end = bv(create_bitvector_from_file(end_file));
bit_vector start_bv = create_bitvector_from_file(start_file);
bit_vector end_bv = create_bitvector_from_file(end_file);
build_from_bitvectors(start_bv, end_bv);
}
template<class bv>
void Coverind<bv>::build_from_bitvectors(const bit_vector &start_bv, const bit_vector &end_bv) {
start = bv(start_bv);
end = bv(end_bv);
create_rank_select();
}
template <class bv>
void Coverind<bv>::create_rank_select() {
rank_start = typename bv::rank_1_type(&start);
rank_end = typename bv::rank_1_type(&end);
......@@ -89,11 +106,7 @@ Coverind<bv>::Coverind(const std::string index) {
load_from_file(start, index+std::string(".start.bv"));
load_from_file(end, index +std::string(".end.bv"));
rank_start = typename bv::rank_1_type(&start);
rank_end = typename bv::rank_1_type(&end);
select_start = typename bv::select_0_type(&start);
select_end = typename bv::select_0_type(&end);
create_rank_select();
}
template <class bv>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment