Home | History | Annotate | Download | only in util
      1 // Copyright 2005-2009 The RE2 Authors.  All Rights Reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 // Modified from Google perftools's tcmalloc_unittest.cc.
      6 
      7 #ifndef RE2_UTIL_RANDOM_H__
      8 #define RE2_UTIL_RANDOM_H__
      9 
     10 #include "util/util.h"
     11 
     12 namespace re2 {
     13 
     14 // ACM minimal standard random number generator.  (re-entrant.)
     15 class ACMRandom {
     16  public:
     17   ACMRandom(int32 seed) : seed_(seed) {}
     18   int32 Next();
     19   int32 Uniform(int32);
     20 
     21   void Reset(int32 seed) { seed_ = seed; }
     22 
     23  private:
     24   int32 seed_;
     25 };
     26 
     27 }  // namespace re2
     28 
     29 #endif  // RE2_UTIL_RANDOM_H__
     30