summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorulrich.bauer@gmail.com <ulrich.bauer@gmail.com@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2014-06-03 13:30:25 +0000
committerulrich.bauer@gmail.com <ulrich.bauer@gmail.com@8e3bb3c2-eed4-f18f-5264-0b6c94e6926d>2014-06-03 13:30:25 +0000
commitb954f5b493c0ced69a18d75c6df4a3d84ccbef9f (patch)
tree8a6c07d610d4fe7da4acf0ff3cbb3162682a3f3e
parent0475a70d2d3581fde6f9481ef25aeba21329da47 (diff)
faster column addition for vector_vector
git-svn-id: https://phat.googlecode.com/svn/trunk@180 8e3bb3c2-eed4-f18f-5264-0b6c94e6926d
-rw-r--r--include/phat/representations/vector_vector.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/include/phat/representations/vector_vector.h b/include/phat/representations/vector_vector.h
index da8ec5a..4aee533 100644
--- a/include/phat/representations/vector_vector.h
+++ b/include/phat/representations/vector_vector.h
@@ -83,11 +83,18 @@ namespace phat {
column& source_col = matrix[ source ];
column& target_col = matrix[ target ];
column& temp_col = temp_column_buffer();
- temp_col.clear();
- std::set_symmetric_difference( target_col.begin(), target_col.end(),
+
+
+ size_t new_size = source_col.size() + target_col.size();
+
+ if (new_size > temp_col.size()) temp_col.resize(new_size);
+
+ std::vector<index>::iterator col_end = std::set_symmetric_difference( target_col.begin(), target_col.end(),
source_col.begin(), source_col.end(),
- std::back_inserter( temp_col ) );
- //target_col.swap( temp_col );
+ temp_col.begin() );
+ temp_col.erase(col_end, temp_col.end());
+
+
target_col = temp_col;
temp_col.clear();
}