First public contribution.
1 /***********************************************************************************
5 * Mark of the Unicorn, Inc.
7 * Permission to use, copy, modify, distribute and sell this software
8 * and its documentation for any purpose is hereby granted without fee,
9 * provided that the above copyright notice appear in all copies and
10 * that both that copyright notice and this permission notice appear
11 * in supporting documentation. Mark of the Unicorn makes no
12 * representations about the suitability of this software for any
13 * purpose. It is provided "as is" without express or implied warranty.
15 ***********************************************************************************/
16 #include "random_number.h"
18 #if defined (EH_NEW_HEADERS)
19 # include <functional>
22 # include <function.h>
26 unsigned random_number( size_t range )
28 #if !defined( __SGI_STL )
29 if (range == 0) return 0;
30 return (unsigned)(EH_STD::rand() + EH_STD::rand()) % range;
32 static EH_STD::subtractive_rng rnd;
33 if (range==0) return 0;
38 // default base for random container sizes
39 unsigned random_base = 1000;