Unverified Commit ade9bd51 authored by Guolin Ke's avatar Guolin Ke Committed by GitHub
Browse files

update sampling solution (#2693)

parent b161f334
...@@ -84,10 +84,10 @@ class Random { ...@@ -84,10 +84,10 @@ class Random {
} }
} else { } else {
std::set<int> sample_set; std::set<int> sample_set;
while (static_cast<int>(sample_set.size()) < K) { for (int r = N - K; r < N; ++r) {
int next = RandInt32() % N; int v = NextInt(0, r);
if (sample_set.count(next) == 0) { if (!sample_set.insert(v).second) {
sample_set.insert(next); sample_set.insert(r);
} }
} }
for (auto iter = sample_set.begin(); iter != sample_set.end(); ++iter) { for (auto iter = sample_set.begin(); iter != sample_set.end(); ++iter) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment