Unverified Commit 42ddff1d authored by shiyu1994's avatar shiyu1994 Committed by GitHub
Browse files

fix Sample when sampling only one element (fix #4134) (#4324)

parent 4167649c
...@@ -82,6 +82,9 @@ class Random { ...@@ -82,6 +82,9 @@ class Random {
ret.push_back(i); ret.push_back(i);
} }
} }
} else if (K == 1) {
int v = NextInt(0, N);
ret.push_back(v);
} else { } else {
std::set<int> sample_set; std::set<int> sample_set;
for (int r = N - K; r < N; ++r) { for (int r = N - K; r < N; ++r) {
......
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