diff options
Diffstat (limited to 'decoder/sparse_vector.h')
-rw-r--r-- | decoder/sparse_vector.h | 5 |
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); |