| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef BASE_RAND_UTIL_H_ | 5 #ifndef BASE_RAND_UTIL_H_ |
| 6 #define BASE_RAND_UTIL_H_ | 6 #define BASE_RAND_UTIL_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <string> |
| 10 |
| 9 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 10 | 12 |
| 11 namespace base { | 13 namespace base { |
| 12 | 14 |
| 13 // Returns a random number in range [0, kuint64max]. Thread-safe. | 15 // Returns a random number in range [0, kuint64max]. Thread-safe. |
| 14 uint64 RandUint64(); | 16 uint64 RandUint64(); |
| 15 | 17 |
| 16 // Returns a random number between min and max (inclusive). Thread-safe. | 18 // Returns a random number between min and max (inclusive). Thread-safe. |
| 17 int RandInt(int min, int max); | 19 int RandInt(int min, int max); |
| 18 | 20 |
| 19 // Returns a random number in range [0, max). Thread-safe. | 21 // Returns a random number in range [0, max). Thread-safe. |
| 20 // | 22 // |
| 21 // Note that this can be used as an adapter for std::random_shuffle(): | 23 // Note that this can be used as an adapter for std::random_shuffle(): |
| 22 // Given a pre-populated |std::vector<int> myvector|, shuffle it as | 24 // Given a pre-populated |std::vector<int> myvector|, shuffle it as |
| 23 // std::random_shuffle(myvector.begin(), myvector.end(), base::RandGenerator); | 25 // std::random_shuffle(myvector.begin(), myvector.end(), base::RandGenerator); |
| 24 uint64 RandGenerator(uint64 max); | 26 uint64 RandGenerator(uint64 max); |
| 25 | 27 |
| 26 // Returns a random double in range [0, 1). Thread-safe. | 28 // Returns a random double in range [0, 1). Thread-safe. |
| 27 double RandDouble(); | 29 double RandDouble(); |
| 28 | 30 |
| 31 // Generate a 128-bit random GUID of the form: "%08X-%04X-%04X-%04X-%012llX". |
| 32 std::string GenerateGUID(); |
| 33 |
| 29 } // namespace base | 34 } // namespace base |
| 30 | 35 |
| 31 #endif // BASE_RAND_UTIL_H_ | 36 #endif // BASE_RAND_UTIL_H_ |
| OLD | NEW |