diff options
Diffstat (limited to 'decoder/sparse_vector.h')
-rw-r--r-- | decoder/sparse_vector.h | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/decoder/sparse_vector.h b/decoder/sparse_vector.h index 6a8c9bf4..2b4a63a9 100644 --- a/decoder/sparse_vector.h +++ b/decoder/sparse_vector.h @@ -185,10 +185,15 @@ public: } std::ostream &operator<<(std::ostream &out) const { + bool first = true; for (typename std::map<int, T>::const_iterator - it = _values.begin(); it != _values.end(); ++it) - out << (it == _values.begin() ? "" : ";") - << FD::Convert(it->first) << '=' << it->second; + it = _values.begin(); it != _values.end(); ++it) { + // by definition feature id 0 is a dummy value + if (it->first == 0) continue; + out << (first ? "" : ";") + << FD::Convert(it->first) << '=' << it->second; + first = false; + } return out; } @@ -216,6 +221,9 @@ public: void clear() { _values.clear(); } + void clear_value(int index) { + _values.erase(index); + } void swap(SparseVector<T>& other) { _values.swap(other._values); |