Skip to content

Commit

Permalink
Easier way to swap index in GBWTBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
jltsiren committed Nov 9, 2017
1 parent 7b91e2a commit 38240bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions dynamic_gbwt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,7 @@ DynamicGBWT::insert(text_buffer_type& text, size_type batch_size, bool both_orie

// Create a builder using this index.
GBWTBuilder builder(text.width(), batch_size);
builder.index.swap(*this);
builder.swapIndex(*this);

// Insert all sequences.
std::vector<node_type> sequence;
Expand All @@ -682,7 +682,7 @@ DynamicGBWT::insert(text_buffer_type& text, size_type batch_size, bool both_orie

// Finish the construction and get the index contents back.
builder.finish();
this->swap(builder.index);
builder.swapIndex(*this);

if(Verbosity::level >= Verbosity::BASIC)
{
Expand Down Expand Up @@ -859,6 +859,12 @@ GBWTBuilder::~GBWTBuilder()
if(this->builder.joinable()) { this->builder.join(); }
}

void
GBWTBuilder::swapIndex(DynamicGBWT& another_index)
{
this->index.swap(another_index);
}

void
GBWTBuilder::insert(std::vector<node_type>& sequence, bool both_orientations)
{
Expand Down
2 changes: 2 additions & 0 deletions include/gbwt/dynamic_gbwt.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ class GBWTBuilder
GBWTBuilder(size_type node_width, size_type batch_size = DynamicGBWT::INSERT_BATCH_SIZE);
~GBWTBuilder();

void swapIndex(DynamicGBWT& another_index);

void insert(std::vector<node_type>& sequence, bool both_orientations = false);
void finish();

Expand Down

0 comments on commit 38240bb

Please sign in to comment.