mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
FIXUP: More comments about shuffle
This commit is contained in:
parent
8791a44e01
commit
9a559b5475
@ -6,6 +6,10 @@
|
||||
|
||||
/* Reorders the elements in the given range [first, last) such that each
|
||||
* possible permutation of those elements has equal probability of appearance.
|
||||
*
|
||||
* for i ∈ [0, n-2):
|
||||
* j ← random from ∈ [i, n)
|
||||
* swap arr[i] ↔ arr[j]
|
||||
*/
|
||||
template <typename Iter, typename Rng>
|
||||
void shuffle(Iter first, Iter last, Rng && rng)
|
||||
@ -28,6 +32,10 @@ void shuffle(Iter first, Iter last, Rng && rng)
|
||||
* [first, first + limit) is a random subset of the original range.
|
||||
* [first + limit, last) shall contain the elements not in [first, first + limit)
|
||||
* in undefined order.
|
||||
*
|
||||
* for i ∈ [0, limit):
|
||||
* j ← random from ∈ [i, n)
|
||||
* swap arr[i] ↔ arr[j]
|
||||
*/
|
||||
template <typename Iter, typename Rng>
|
||||
void partial_shuffle(Iter first, Iter last, size_t limit, Rng && rng)
|
||||
|
@ -36,7 +36,7 @@ struct FunctionArrayShuffleTraits
|
||||
static constexpr auto has_limit = false; // Permute the whole array
|
||||
static ColumnNumbers getArgumentsThatAreAlwaysConstant() { return {1}; }
|
||||
static constexpr auto max_num_params = 2; // array[, seed]
|
||||
static constexpr auto seed_param_idx = 1;
|
||||
static constexpr auto seed_param_idx = 1; // --------^^^^
|
||||
};
|
||||
|
||||
/** Partial shuffle array elements
|
||||
@ -50,7 +50,7 @@ struct FunctionArrayPartialShuffleTraits
|
||||
static constexpr auto has_limit = true;
|
||||
static ColumnNumbers getArgumentsThatAreAlwaysConstant() { return {1, 2}; }
|
||||
static constexpr auto max_num_params = 3; // array[, limit[, seed]]
|
||||
static constexpr auto seed_param_idx = 2;
|
||||
static constexpr auto seed_param_idx = 2; // ----------------^^^^
|
||||
};
|
||||
|
||||
template <typename Traits>
|
||||
|
Loading…
Reference in New Issue
Block a user