os_random_shuffle


Randomizes a container using random shuffles.

A helper algorithm for random_shuffle() . Shuffles all elements in the container c using uniformly selected random swaps. Uses operator= to perform the swaps.

Library

Helper<ToolKit>

Declaration

#include <ospace/helper/helpalgo.h>

template< class Container >
void os_random_shuffle( Container& c )
Example <ospace/helper/examples/orndshf0.cpp>
#include <iostream>
#include <vector>
#include <ospace/helper.h>

int numbers[ 6 ] = { 1, 2, 3, 4, 5, 6 };

void
main()
  {
  vector< int > v( numbers, numbers + 6 );

  os_random_shuffle( v );

  for ( size_t i = 0; i < v.size(); ++i )
    cout << v[ i ] << ` `;
  cout << "\n";
  }

3 1 6 2 4 5

Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.