From a6f3fb188e539eb1eb4d9e0be9fffdf15bdf9170 Mon Sep 17 00:00:00 2001 From: Patrick Simianer Date: Fri, 11 Nov 2011 12:42:24 +0100 Subject: more reporting, size_nonz() for fast sparse vector --- utils/fast_sparse_vector.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'utils') diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h index 8daaac85..8fe6cb3d 100644 --- a/utils/fast_sparse_vector.h +++ b/utils/fast_sparse_vector.h @@ -190,6 +190,14 @@ class FastSparseVector { else return local_size_; } + size_t size_nonzero() const { + size_t sz = 0; + const_iterator it = this->begin(); + for (; it != this->end(); ++it) { + if (nonzero(it->first)) sz++; + } + return sz; + } inline void clear() { if (is_remote_) delete data_.rbmap; is_remote_ = false; -- cgit v1.2.3