summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorgraehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-15 05:05:19 +0000
committergraehl@gmail.com <graehl@gmail.com@ec762483-ff6d-05da-a07a-a48fb63a330f>2010-08-15 05:05:19 +0000
commit214c741eee9b01ccd05a1825ad9ed647adef41db (patch)
tree4164371d19ea6e62c6d801971d045edaf5bb5fdb /utils
parent8078d0be612c4ff89e3cb7dd31af077c0be6d0d9 (diff)
fixed binarization. test
git-svn-id: https://ws10smt.googlecode.com/svn/trunk@554 ec762483-ff6d-05da-a07a-a48fb63a330f
Diffstat (limited to 'utils')
-rwxr-xr-xutils/batched_append.h2
-rw-r--r--utils/sparse_vector.h6
2 files changed, 5 insertions, 3 deletions
diff --git a/utils/batched_append.h b/utils/batched_append.h
index 14a6d576..842f3209 100755
--- a/utils/batched_append.h
+++ b/utils/batched_append.h
@@ -13,7 +13,7 @@ void batched_append(Vector &v,SRange const& s) {
template <class SRange,class Vector>
void batched_append_swap(Vector &v,SRange & s) {
- using namespace std; // to find the right swap
+ using namespace std; // to find the right swap via ADL
size_t i=v.size();
size_t news=i+s.size();
v.resize(news);
diff --git a/utils/sparse_vector.h b/utils/sparse_vector.h
index 7ac85d1d..e3904403 100644
--- a/utils/sparse_vector.h
+++ b/utils/sparse_vector.h
@@ -145,7 +145,7 @@ public:
if (!(s>>v)) error("reading value failed");
}
std::pair<iterator,bool> vi=values_.insert(value_type(k,v));
- if (vi.second) {
+ if (!vi.second) {
T &oldv=vi.first->second;
switch(dp) {
case NO_DUPS: error("read duplicate key with NO_DUPS. key="
@@ -157,9 +157,11 @@ public:
}
}
}
- return;
+ goto good;
eof:
if (!s.eof()) error("reading key failed (before EOF)");
+ good:
+ s.clear(); // we may have reached eof, but that's no error.
}
friend inline std::ostream & operator<<(std::ostream &o,Self const& s) {