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

Side by Side Diff: media/blink/test_random.h

Issue 1427433012: Simple LRU class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month 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
« media/blink/lru_unittest.cc ('K') | « media/blink/media_blink.gyp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 The Chromium Authors. All rights reserved.
xhwang 2015/11/10 00:50:01 2015
hubbe 2015/11/10 18:26:15 Done.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef MEDIA_BLINK_TEST_RANDOM_H_
6 #define MEDIA_BLINK_TEST_RANDOM_H_
7
8 // Vastly simplified ACM random class meant to only be used for testing.
xhwang 2015/11/10 00:50:01 Could you please provide more context here why met
hubbe 2015/11/10 18:26:15 Done.
9
10 namespace media {
11
12 class TestRandom {
13 public:
14 explicit TestRandom(uint32 seed) {
xhwang 2015/11/10 00:50:01 nit: for new files use uint32_t as per style guide
hubbe 2015/11/10 18:26:15 Done.
15 seed_ = seed & 0x7fffffff; // make this a non-negative number
16 if (seed_ == 0 || seed_ == M) {
17 seed_ = 1;
18 }
19 }
20
21 int32 Rand() {
22 static const uint64 A = 16807; // bits 14, 8, 7, 5, 2, 1, 0
23 seed_ = static_cast<int32>((seed_ * A) % M);
24 CHECK_GT(seed_, 0);
25 return seed_;
26 }
27
28 private:
29 static const uint64 M = 2147483647L; // 2^32-1
30 int32 seed_;
31 };
32
33 } // namespace media
34
35 #endif // MEDIA_BLINK_TEST_RANDOM_H_
OLDNEW
« media/blink/lru_unittest.cc ('K') | « media/blink/media_blink.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698