Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: base/rand_util.h

Issue 3053050: Add RandomNumberGenerator adapter to base/rand_util.h (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Compile on Windows, too... Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | base/rand_util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 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 "base/basictypes.h" 9 #include "base/basictypes.h"
10 10
11 namespace base { 11 namespace base {
12 12
13 // Returns a random number in range [0, kuint64max]. Thread-safe. 13 // Returns a random number in range [0, kuint64max]. Thread-safe.
14 uint64 RandUint64(); 14 uint64 RandUint64();
15 15
16 // Returns a random number between min and max (inclusive). Thread-safe. 16 // Returns a random number between min and max (inclusive). Thread-safe.
17 int RandInt(int min, int max); 17 int RandInt(int min, int max);
18 18
19 // Returns a random number in range [0, max). Thread-safe.
20 //
21 // 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
23 // std::random_shuffle(myvector.begin(), myvector.end(), base::RandGenerator);
24 uint64 RandGenerator(uint64 max);
Paweł Hajdan Jr. 2010/08/30 18:09:02 I think I'd prefer a RandomShuffle thing. The impl
25
19 // Returns a random double in range [0, 1). Thread-safe. 26 // Returns a random double in range [0, 1). Thread-safe.
20 double RandDouble(); 27 double RandDouble();
21 28
22 } // namespace base 29 } // namespace base
23 30
24 #endif // BASE_RAND_UTIL_H_ 31 #endif // BASE_RAND_UTIL_H_
OLDNEW
« no previous file with comments | « no previous file | base/rand_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698