blob: 699fc7fabbec89065ad3a4afe0146c524b050b0f [file] [log] [blame]
isherman@chromium.org01eaa0b2010-08-31 06:07:05 +09001// Copyright (c) 2010 The Chromium Authors. All rights reserved.
mark@chromium.orgb93c0542008-09-30 07:18:01 +09002// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef BASE_RAND_UTIL_H_
6#define BASE_RAND_UTIL_H_
thakis@chromium.org01d14522010-07-27 08:08:24 +09007#pragma once
mark@chromium.orgb93c0542008-09-30 07:18:01 +09008
9#include "base/basictypes.h"
10
11namespace base {
12
13// Returns a random number in range [0, kuint64max]. Thread-safe.
deanm@chromium.org48c40ce2008-11-15 08:28:29 +090014uint64 RandUint64();
mark@chromium.orgb93c0542008-09-30 07:18:01 +090015
16// Returns a random number between min and max (inclusive). Thread-safe.
17int RandInt(int min, int max);
18
isherman@chromium.org01eaa0b2010-08-31 06:07:05 +090019// 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);
24uint64 RandGenerator(uint64 max);
25
mark@chromium.orgb93c0542008-09-30 07:18:01 +090026// Returns a random double in range [0, 1). Thread-safe.
27double RandDouble();
28
29} // namespace base
30
erg@google.combf6ce9f2010-01-27 08:08:02 +090031#endif // BASE_RAND_UTIL_H_