Given a function random_num_in_range
(more on that later), it shouldn't be that hard to roll your own sampler:
// Samples randomly from (b, e) into o, n elements
template<typename It, typename OutIt>
void sample(It b, It e, OutIt o, size_t n)
{
// Number of elements in range.
const size_t s = std::distance(b, e);
// Generate n samples.
for(size_t i = 0; i < n; ++i)
{
It it = b;
// Move b iterator random number of steps forward.
std::advance(it, random_num_in_range(s));
// Write into output
*(o++) = *it;
}
}
You'd use it possibly like this:
vector<int> input;
...
vector<int> output;
sample(input.begin(), input.end(), back_inserter(output), 100);
The question is how to write random_number_in_range
without contemporary libraries. I suggest you look at this question, but skip past the accepted answer (which I've flagged for moderator attention, as I believe someone edited it into something completely wrong).