<commit_before>/**
 * @file RandGenerator.h
 * @brief generate random item ids
 * @author <NAME>
 * @date 2011-11-30
 */

#ifndef RAND_GENERATOR_H
#define RAND_GENERATOR_H

#include <util/ThreadModel.h>

#include <boost/random.hpp>

namespace sf1r
{

template<typename ValueType = int,
         typename Distribution = boost::uniform_int<ValueType>,
         typename Engine = boost::mt19937,
         typename LockType = izenelib::util::ReadWriteLock>
class RandGenerator
{
public:
    RandGenerator()
        : generator_(Engine(), Distribution())
    {}

    void seed(int value)
    {
        ScopedWriteLock lock(lock_);

        generator_.engine().seed(value);
    }

    ValueType generate(ValueType min, ValueType max)
    {
        ScopedWriteLock lock(lock_);

        Distribution& dist = generator_.distribution();
        if (dist.min() != min || dist.max() != max)
        {
            dist = Distribution(min, max);
        }<commit_msg>Fix compile error under boost 1.38, caused by boost/random.hpp seed()<commit_after>/**
 * @file RandGenerator.h
 * @brief generate random item ids
 * @author <NAME>
 * @date 2011-11-30
 */

#ifndef RAND_GENERATOR_H
#define RAND_GENERATOR_H

#include <util/ThreadModel.h>

#include <boost/random.hpp>

namespace sf1r
{

template<typename ValueType = int,
         typename Distribution = boost::uniform_int<ValueType>,
         typename Engine = boost::mt19937,
         typename LockType = izenelib::util::ReadWriteLock>
class RandGenerator
{
public:
    RandGenerator()
        : generator_(Engine(), Distribution())
    {}

    void seed(unsigned int value)
    {
        ScopedWriteLock lock(lock_);

        Engine& engine = generator_.engine();
        engine.seed(value);		
    }

    ValueType generate(ValueType min, ValueType max)
    {
        ScopedWriteLock lock(lock_);

        Distribution& dist = generator_.distribution();
        if (dist.min() != min || dist.max() != max)
        {
            dist = Distribution(min, max);
        }
{'fraction_non_alphanumeric': 0.11902390438247012, 'fraction_numerical': 0.015438247011952191, 'mean_word_length': 2.8783783783783785, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3216837', 'n_tokens_mistral': 621, 'n_tokens_neox': 582, 'n_words': 141}