11 Aralık 2019 Çarşamba

std::sample

Örnek
Şöyle yaparız.
template<typename T>
std::vector<T> sampling(const std::vector<T>& input, std::size_t k) {
    std::vector<T> output;
    output.reserve(k);
    std::sample(input.begin(), input.end(), std::back_inserter(output),
        k, std::mt19937{std::random_device{}()});    

    // the relative order of elements in output is the same as in input
    return output;
}

Hiç yorum yok:

Yorum Gönder