Skip to content

Commit 3604a5a

Browse files
committed
some more fixes
1 parent 4a069f3 commit 3604a5a

2 files changed

Lines changed: 9 additions & 6 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@
66
inst/doc
77
docs
88
__pycache__
9+
smoke_test*

src/multiset.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,12 @@ class MultisetPartitions {
4242

4343
explicit operator bool() const { return !done; }
4444
value_type operator*() { return get(); }
45-
pointer operator->() const { return &get(); }
4645

47-
iterator& operator++() { done = next(); return *this; }
46+
iterator& operator++() {
47+
done = next();
48+
Rcpp::checkUserInterrupt();
49+
return *this;
50+
}
4851
iterator operator++(int) { auto it = *this; ++*this; return it; }
4952

5053
friend bool operator==(const iterator& lhs, const iterator& rhs) {
@@ -139,14 +142,13 @@ class MultisetPartitions {
139142

140143
value_type get() {
141144
value_type partition;
145+
partition.reserve(l + 1);
142146
for (int i = 0; i <= l; i++) {
143147
std::vector<T> part;
144-
for (int j = f[i]; j < f[i + 1]; j++) {
148+
for (int j = f[i]; j < f[i + 1]; j++)
145149
for (int k = 0; k < v[j]; k++)
146150
part.push_back(obj->comp[c[j]]);
147-
Rcpp::checkUserInterrupt();
148-
}
149-
partition.push_back(part);
151+
partition.push_back(std::move(part));
150152
}
151153
return partition;
152154
}

0 commit comments

Comments
 (0)