diff options
author | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2011-11-11 12:42:24 +0100 |
---|---|---|
committer | Patrick Simianer <simianer@cl.uni-heidelberg.de> | 2011-11-11 12:42:24 +0100 |
commit | ed8ca37550910a540e755ada119e814f13eeef03 (patch) | |
tree | 1a739dff236c82ac495115099633146d76d99e86 /utils/fast_sparse_vector.h | |
parent | 7fdee2f485e79d932449827ad11eeee5b9b51eb0 (diff) |
more reporting, size_nonz() for fast sparse vector
Diffstat (limited to 'utils/fast_sparse_vector.h')
-rw-r--r-- | utils/fast_sparse_vector.h | 8 |
1 files changed, 8 insertions, 0 deletions
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; |