mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
[yul-phaser] Selections+PairSelections: Add RandomSubset and PairsFromRandomSubset
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
#include <tools/yulPhaser/SimulationRNG.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <numeric>
|
||||
|
||||
using namespace std;
|
||||
using namespace solidity::phaser;
|
||||
@@ -58,3 +59,12 @@ vector<size_t> RandomSelection::materialise(size_t _poolSize) const
|
||||
return selection;
|
||||
}
|
||||
|
||||
vector<size_t> RandomSubset::materialise(size_t _poolSize) const
|
||||
{
|
||||
vector<size_t> selection;
|
||||
for (size_t index = 0; index < _poolSize; ++index)
|
||||
if (SimulationRNG::bernoulliTrial(m_selectionChance))
|
||||
selection.push_back(index);
|
||||
|
||||
return selection;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user