diff options
author | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 02:46:13 +0000 |
---|---|---|
committer | graehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-08-11 02:46:13 +0000 |
commit | 82384b4ec365f3d2ad2c9bca078a0b38d4be09c0 (patch) | |
tree | f6f015f2791ec9b1ec94c90c98b09c0d251aee9e /decoder/batched_append.h | |
parent | e4e66118c14704509e214aa32689ef304ae5ada2 (diff) |
merge
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@511 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/batched_append.h')
-rwxr-xr-x | decoder/batched_append.h | 25 |
1 files changed, 25 insertions, 0 deletions
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 <algorithm> //swap +#include <cstddef> + +template <class SRange,class Vector> +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 <class SRange,class Vector> +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<news;++i,++si) + swap(v[i],*si); +} + +#endif |