DTL

Shuffling

Fisher-Yates shuffle

Is an algorithm for generating a random permutation of a finite sequence in linear time and constant space.

Using Fisher-Yates shuffle with DTL

#include "vector.hpp"
#include "fisher_yates.hpp"
#include <iostream>

int main() {
  srand(time(0));
  dby::vector<int> vec = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };

  dby::FisherYates::shuffle(vec);

  for (int num : vec) {
    std::cout << num << ' ';
  }
  return 0;
}