OLD | NEW |
1 //===- subzero/src/IceRNG.h - Random number generator -----------*- C++ -*-===// | 1 //===- subzero/src/IceRNG.h - Random number generator -----------*- C++ -*-===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
11 /// This file declares a random number generator. | 11 /// \brief Declares a random number generator. |
12 /// | 12 /// |
13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
14 | 14 |
15 #ifndef SUBZERO_SRC_ICERNG_H | 15 #ifndef SUBZERO_SRC_ICERNG_H |
16 #define SUBZERO_SRC_ICERNG_H | 16 #define SUBZERO_SRC_ICERNG_H |
17 | 17 |
18 #include "llvm/ADT/StringRef.h" | 18 #include "llvm/ADT/StringRef.h" |
19 #include "llvm/Support/Compiler.h" | 19 #include "llvm/Support/Compiler.h" |
20 #include "IceDefs.h" | 20 #include "IceDefs.h" |
21 | 21 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 /// at cppreference.com. | 76 /// at cppreference.com. |
77 template <class RandomIt, class RandomFunc> | 77 template <class RandomIt, class RandomFunc> |
78 void RandomShuffle(RandomIt First, RandomIt Last, RandomFunc &&RNG) { | 78 void RandomShuffle(RandomIt First, RandomIt Last, RandomFunc &&RNG) { |
79 for (auto i = Last - First - 1; i > 0; --i) | 79 for (auto i = Last - First - 1; i > 0; --i) |
80 std::swap(First[i], First[RNG(i + 1)]); | 80 std::swap(First[i], First[RNG(i + 1)]); |
81 } | 81 } |
82 | 82 |
83 } // end of namespace Ice | 83 } // end of namespace Ice |
84 | 84 |
85 #endif // SUBZERO_SRC_ICERNG_H | 85 #endif // SUBZERO_SRC_ICERNG_H |
OLD | NEW |