diff options
author | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-12-01 05:27:13 +0000 |
---|---|---|
committer | redpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f> | 2010-12-01 05:27:13 +0000 |
commit | d52db01a2e224869c6ea72a4a234e888c6fd756c (patch) | |
tree | c5aff0967b4fcca2ac879aecb4ac68317d3582aa /utils | |
parent | ca83fbe4c043b2e4e18a21f91e74dfa922eda44e (diff) |
alternative def of neighborhoods
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@739 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils')
-rw-r--r-- | utils/sparse_vector.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/utils/sparse_vector.h b/utils/sparse_vector.h index cce6c8a4..f76fc14c 100644 --- a/utils/sparse_vector.h +++ b/utils/sparse_vector.h @@ -361,6 +361,18 @@ public: return *this; } + template <typename R> + SparseVector<T> &operator+=(const SparseVector<R> &other) { + for (typename SparseVector<R>::MapType::const_iterator + it = other.values_.begin(); it != other.values_.end(); ++it) + { +// T v = + (values_[it->first] += it->second); +// if (!v) values_.erase(it->first); + } + return *this; + } + SparseVector<T> &operator-=(const SparseVector<T> &other) { for (typename MapType::const_iterator it = other.values_.begin(); it != other.values_.end(); ++it) @@ -512,8 +524,8 @@ public: values_.swap(other.values_); } -private: MapType values_; +private: #if HAVE_BOOST_ARCHIVE_TEXT_OARCHIVE_HPP friend class boost::serialization::access; |