summaryrefslogtreecommitdiff
path: root/utils/sparse_vector.h
diff options
context:
space:
mode:
Diffstat (limited to 'utils/sparse_vector.h')
-rw-r--r--utils/sparse_vector.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/utils/sparse_vector.h b/utils/sparse_vector.h
index f76fc14c..1bcb9502 100644
--- a/utils/sparse_vector.h
+++ b/utils/sparse_vector.h
@@ -201,6 +201,11 @@ public:
return found==values_.end() || !found->second;
}
+ void remove_zeros() {
+ typename MapType::iterator it = values_.begin();
+ for (; it != values_.end(); ++it)
+ if (!it->second) values_.erase(it);
+ }
T get(int index) const {
typename MapType::const_iterator found = values_.find(index);