summaryrefslogtreecommitdiffstats
path: root/base/rand_util.h
diff options
context:
space:
mode:
authorisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-30 21:07:05 +0000
committerisherman@chromium.org <isherman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-30 21:07:05 +0000
commita74dcaeaa91acee7dde40b9680eb6e0e30df11fd (patch)
tree41d17386b9ed6f7b4266d3332860c954b64358e9 /base/rand_util.h
parentbf898dad1b57c6fd436bc8d8c8ef143e3d11755d (diff)
downloadchromium_src-a74dcaeaa91acee7dde40b9680eb6e0e30df11fd.zip
chromium_src-a74dcaeaa91acee7dde40b9680eb6e0e30df11fd.tar.gz
chromium_src-a74dcaeaa91acee7dde40b9680eb6e0e30df11fd.tar.bz2
Add RandomNumberGenerator adapter to base/rand_util.h
BUG=46679 TEST=none (yet...) Review URL: http://codereview.chromium.org/3053050 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57904 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/rand_util.h')
-rw-r--r--base/rand_util.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/base/rand_util.h b/base/rand_util.h
index 451a7d1..699fc7f 100644
--- a/base/rand_util.h
+++ b/base/rand_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -16,6 +16,13 @@ uint64 RandUint64();
// Returns a random number between min and max (inclusive). Thread-safe.
int RandInt(int min, int max);
+// Returns a random number in range [0, max). Thread-safe.
+//
+// Note that this can be used as an adapter for std::random_shuffle():
+// Given a pre-populated |std::vector<int> myvector|, shuffle it as
+// std::random_shuffle(myvector.begin(), myvector.end(), base::RandGenerator);
+uint64 RandGenerator(uint64 max);
+
// Returns a random double in range [0, 1). Thread-safe.
double RandDouble();