summaryrefslogtreecommitdiff
path: root/utils/sparse_vector.h
diff options
context:
space:
mode:
authorredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-12-01 05:27:13 +0000
committerredpony <redpony@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-12-01 05:27:13 +0000
commit5694fc704f0c7b040c28f88a034e67a1ed19d3ba (patch)
tree5ee46a3429414b1c1cdf9712f27a645b7438eed6 /utils/sparse_vector.h
parent083e28a2694df51a4631d81347c45f57a5182560 (diff)
alternative def of neighborhoods
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@739 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils/sparse_vector.h')
-rw-r--r--utils/sparse_vector.h14
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;