summaryrefslogtreecommitdiff
path: root/decoder/sparse_vector.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-08 19:12:59 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-08 19:12:59 +0000
commit71b39bcf60182d1686966db34225a670d13e3594 (patch)
treebe260c40aaaeca1a70df4187c5abf7c167d74b1c /decoder/sparse_vector.h
parent337b647baac15609a0a493902d58c473d25d2ed8 (diff)
misc
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@185 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/sparse_vector.h')
-rw-r--r--decoder/sparse_vector.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h
index 26f5d791..7794fd5e 100644
--- a/decoder/sparse_vector.h
+++ b/decoder/sparse_vector.h
@@ -18,6 +18,11 @@ public:
typedef std::map<int, T> MapType;
typedef typename std::map<int, T>::const_iterator const_iterator;
SparseVector() {}
+ explicit SparseVector(std::vector<T> const& v) {
+ MapType::iterator p=values_.end();
+ for (unsigned i=0;i<v.size();++i)
+ p=values_.insert(p,MapType::value_type(i,v[i])); //faster
+ }
const T operator[](int index) const {
typename MapType::const_iterator found = values_.find(index);