summaryrefslogtreecommitdiff
path: root/utils/fast_sparse_vector.h
diff options
context:
space:
mode:
authorChris Dyer <cdyer@cs.cmu.edu>2012-08-12 02:14:57 -0400
committerChris Dyer <cdyer@cs.cmu.edu>2012-08-12 02:14:57 -0400
commitffd4f84d33109e4146ad0f3fd5c6100e02150888 (patch)
tree980aae9e0a663be7620a90f1d79c1a181335754f /utils/fast_sparse_vector.h
parentccdb3061d1e582a5abd412b37ee0da2278f45706 (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.h7
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) {