2008-11-29 15:30:50 +00:00
|
|
|
|
|
|
|
#ifndef BOOST_UNIFORM_INT_INCLUDED
|
|
|
|
#define BOOST_UNIFORM_INT_INCLUDED
|
|
|
|
|
|
|
|
namespace boost
|
|
|
|
{
|
|
|
|
template <typename IntType = unsigned int>
|
|
|
|
class uniform_int
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
typedef IntType type;
|
|
|
|
|
|
|
|
uniform_int (IntType _first, IntType _last)
|
|
|
|
: first (_first)
|
|
|
|
, last (_last)
|
|
|
|
{}
|
|
|
|
|
|
|
|
IntType operator () (IntType in)
|
|
|
|
{
|
|
|
|
return (IntType)((in * ((last-first)/RAND_MAX)) + first);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
IntType first, last;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2009-01-12 22:26:11 +00:00
|
|
|
#endif // BOOST_UNIFORM_INT_INCLUDED
|