summaryrefslogtreecommitdiff
path: root/utils/sparse_vector.h
diff options
context:
space:
mode:
authorJonathan Clark <jon.h.clark@gmail.com>2011-03-10 06:54:59 -0500
committerJonathan Clark <jon.h.clark@gmail.com>2011-03-10 06:54:59 -0500
commit7491d7f72bd50cbc08a28f64cc3939a310d65801 (patch)
treefe18c5bc6ca1e0bf18f0ca473833162ecd3a908b /utils/sparse_vector.h
parent8c8ff6c6915ebc5ce30156e3f05bf8d1966ec0a1 (diff)
parent4f9933d668d247ea5831c3f2af0b996a94da28f7 (diff)
Merge branch 'master' of git://github.com/redpony/cdec
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);