From b22b4fb953987d6a19716af8c3f8af73826bcfca Mon Sep 17 00:00:00 2001 From: graehl Date: Wed, 11 Aug 2010 02:46:13 +0000 Subject: merge git-svn-id: https://ws10smt.googlecode.com/svn/trunk@511 ec762483-ff6d-05da-a07a-a48fb63a330f --- decoder/batched_append.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100755 decoder/batched_append.h (limited to 'decoder/batched_append.h') diff --git a/decoder/batched_append.h b/decoder/batched_append.h new file mode 100755 index 00000000..745f567f --- /dev/null +++ b/decoder/batched_append.h @@ -0,0 +1,25 @@ +#ifndef BATCHED_APPEND_H +#define BATCHED_APPEND_H + +#include //swap +#include + +template +void batched_append(Vector &v,SRange const& s) { + std::size_t news=v.size()+s.size(); + v.reserve(news); + v.insert(v.end(),s.begin(),s.end()); +} + +template +void batched_append_swap(Vector &v,SRange & s) { + using namespace std; // to find the right swap + size_t i=v.size(); + size_t news=i+s.size(); + v.resize(news); + typename SRange::iterator_type si=s.begin(); + for (;i