From 5694fc704f0c7b040c28f88a034e67a1ed19d3ba Mon Sep 17 00:00:00 2001 From: redpony Date: Wed, 1 Dec 2010 05:27:13 +0000 Subject: alternative def of neighborhoods git-svn-id: https://ws10smt.googlecode.com/svn/trunk@739 ec762483-ff6d-05da-a07a-a48fb63a330f --- utils/sparse_vector.h | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'utils') 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 + SparseVector &operator+=(const SparseVector &other) { + for (typename SparseVector::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 &operator-=(const SparseVector &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; -- cgit v1.2.3