LCOV - code coverage report
Current view: top level - pg/include/mcrl2/pg - shuffle.h (source / functions) Hit Total Coverage
Test: mcrl2_coverage.info.cleaned Lines: 0 5 0.0 %
Date: 2024-04-13 03:38:08 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : // Copyright (c) 2009-2013 University of Twente
       2             : // Copyright (c) 2009-2013 Michael Weber <michaelw@cs.utwente.nl>
       3             : // Copyright (c) 2009-2013 Maks Verver <maksverver@geocities.com>
       4             : // Copyright (c) 2009-2013 Eindhoven University of Technology
       5             : //
       6             : // Distributed under the Boost Software License, Version 1.0.
       7             : // (See accompanying file LICENSE_1_0.txt or copy at
       8             : // http://www.boost.org/LICENSE_1_0.txt)
       9             : 
      10             : #ifndef MCRL2_PG_SHUFFLE_H
      11             : #define MCRL2_PG_SHUFFLE_H
      12             : 
      13             : #include <algorithm>
      14             : #include <vector>
      15             : #include <cstdlib>
      16             : 
      17             : /* Randomly shuffle the given vector.  This is similar to std::random_shuffle
      18             :    on a vector,  except that this uses rand() while the random source for
      19             :    std::random_shuffle is unspecified. */
      20             : template<class T>
      21           0 : static void shuffle_vector(std::vector<T> &v)
      22             : {
      23           0 :     std::size_t n = v.size();
      24           0 :     for (std::size_t i = 0; i < n; ++i)
      25             :     {
      26           0 :         std::swap(v[i], v[i + rand()%(n - i)]);
      27             :     }
      28           0 : }
      29             : 
      30             : #endif /* ndef MCRL2_PG_SHUFFLE_H */

Generated by: LCOV version 1.14