summaryrefslogtreecommitdiff
path: root/decoder/sparse_vector.h
diff options
context:
space:
mode:
authorgraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-24 21:24:59 +0000
committergraehl <graehl@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-07-24 21:24:59 +0000
commitf216419b6a6eb1afa1c5d1c62d69ea07a67b87b6 (patch)
treebd5acc323a7730e198415fb5ee3ed2d117a2885d /decoder/sparse_vector.h
parent2cb224de7db49b761ac06b031090fe7f846744fe (diff)
compile
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@400 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'decoder/sparse_vector.h')
-rw-r--r--decoder/sparse_vector.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h
index ec623c6e..0325c1ee 100644
--- a/decoder/sparse_vector.h
+++ b/decoder/sparse_vector.h
@@ -115,15 +115,19 @@ public:
values_[index] = value;
}
- void add_value(int index, const T &value) {
- if (!value) return;
+ inline void maybe_add(int index, const T& value) {
+ if (value) add_value(index,value);
+ }
+
+ T& add_value(int index, const T &value) {
#if 1
- values_[index]+=value;
+ return values_[index]+=value;
#else
// this is not really going to be any faster, and we already rely on default init = 0 init
std::pair<typename MapType::iterator,bool> art=values_.insert(std::make_pair(index,value));
T &val=art.first->second;
if (!art.second) val += value; // already existed
+ return val;
#endif
}