From 38240bb3bd9af8e7da2c2563bc8ddb98ad90b7e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jouni=20Sir=C3=A9n?= Date: Thu, 9 Nov 2017 18:31:38 +0000 Subject: [PATCH] Easier way to swap index in GBWTBuilder --- dynamic_gbwt.cpp | 10 ++++++++-- include/gbwt/dynamic_gbwt.h | 2 ++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/dynamic_gbwt.cpp b/dynamic_gbwt.cpp index 49b8841..b1de48b 100644 --- a/dynamic_gbwt.cpp +++ b/dynamic_gbwt.cpp @@ -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 sequence; @@ -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) { @@ -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& sequence, bool both_orientations) { diff --git a/include/gbwt/dynamic_gbwt.h b/include/gbwt/dynamic_gbwt.h index 1747046..ff2591c 100644 --- a/include/gbwt/dynamic_gbwt.h +++ b/include/gbwt/dynamic_gbwt.h @@ -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& sequence, bool both_orientations = false); void finish();