Skip to content

Commit

Permalink
fix: random selector
Browse files Browse the repository at this point in the history
  • Loading branch information
AsPJT committed Nov 30, 2024
1 parent 6a804bd commit 021007e
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions Library/PAX_SAPIENTICA/RandomSelector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,12 @@ namespace paxs {

/// @brief Randomly select pairs of elements from two vectors.
/// @brief 二つの要素数が異なるベクトルからペアをランダムに選択
/// @param result A vector of selected elements.
/// @param num_elements_1 The number of elements to select from the first vector.
/// @param num_elements_2 The number of elements to select from the second vector.
/// @return A vector of selected elements.
//std::vector<std::pair<std::size_t, std::size_t>>
void select(std::vector<std::pair<std::size_t, std::size_t>>& result,
const std::size_t num_elements_1, const std::size_t num_elements_2) {
const std::size_t num_elements = (std::min)(num_elements_1, num_elements_2);

//std::vector<std::pair<std::size_t, std::size_t>> result;
result.clear();
std::unordered_set<std::size_t> used_indices_1;
std::unordered_set<std::size_t> used_indices_2;
Expand All @@ -76,7 +73,17 @@ namespace paxs {
std::size_t index_2 = getRandomIndex(num_elements_2, used_indices_2);
result.emplace_back(index_1, index_2);
}
//return result;
}

/// @brief Randomly select pairs of elements from two vectors.
/// @brief 二つの要素数が異なるベクトルからペアをランダムに選択
/// @param num_elements_1 The number of elements to select from the first vector.
/// @param num_elements_2 The number of elements to select from the second vector.
/// @return A vector of selected elements.
std::vector<std::pair<std::size_t, std::size_t>> select(const std::size_t num_elements_1, const std::size_t num_elements_2) {
std::vector<std::pair<std::size_t, std::size_t>> result;
select(result, num_elements_1, num_elements_2);
return result;
}

private:
Expand Down

0 comments on commit 021007e

Please sign in to comment.