diff options
author | Chris Dyer <cdyer@cs.cmu.edu> | 2012-08-12 02:14:57 -0400 |
---|---|---|
committer | Chris Dyer <cdyer@cs.cmu.edu> | 2012-08-12 02:14:57 -0400 |
commit | 21373c28b7786b51d1e91529ebb189bfbc4c6dd8 (patch) | |
tree | f59f23568b5df4f7f82f8c0bb0f0d98ad3c971fd /utils/fast_sparse_vector.h | |
parent | 7527592aaf4245749845500aca6a7fcc97eb2f17 (diff) |
fix sparse vector api, and add crp helper class
Diffstat (limited to 'utils/fast_sparse_vector.h')
-rw-r--r-- | utils/fast_sparse_vector.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/utils/fast_sparse_vector.h b/utils/fast_sparse_vector.h index 433a5cc5..5647a2a9 100644 --- a/utils/fast_sparse_vector.h +++ b/utils/fast_sparse_vector.h @@ -194,18 +194,19 @@ class FastSparseVector { data_.rbmap = new SPARSE_HASH_MAP<unsigned, T>(first, last); } } - void erase(int k) { + void erase(unsigned k) { if (is_remote_) { data_.rbmap->erase(k); } else { - for (int i = 0; i < local_size_; ++i) { + for (unsigned i = 0; i < local_size_; ++i) { if (data_.local[i].first() == k) { - for (int j = i+1; j < local_size_; ++j) { + for (unsigned j = i+1; j < local_size_; ++j) { data_.local[j-1].first() = data_.local[j].first(); data_.local[j-1].second() = data_.local[j].second(); } } } + --local_size_; } } const FastSparseVector<T>& operator=(const FastSparseVector<T>& other) { |