sl@0: /*********************************************************************************** sl@0: random_number.cpp sl@0: sl@0: * Copyright (c) 1997 sl@0: * Mark of the Unicorn, Inc. sl@0: * sl@0: * Permission to use, copy, modify, distribute and sell this software sl@0: * and its documentation for any purpose is hereby granted without fee, sl@0: * provided that the above copyright notice appear in all copies and sl@0: * that both that copyright notice and this permission notice appear sl@0: * in supporting documentation. Mark of the Unicorn makes no sl@0: * representations about the suitability of this software for any sl@0: * purpose. It is provided "as is" without express or implied warranty. sl@0: sl@0: ***********************************************************************************/ sl@0: #include "random_number.h" sl@0: #include "Prefix.h" sl@0: #if defined (EH_NEW_HEADERS) sl@0: # include sl@0: # include sl@0: #else sl@0: # include sl@0: # include sl@0: #endif sl@0: sl@0: unsigned random_number( size_t range ) sl@0: { sl@0: #if !defined( __SGI_STL ) sl@0: if (range == 0) return 0; sl@0: return (unsigned)(EH_STD::rand() + EH_STD::rand()) % range; sl@0: #else sl@0: static EH_STD::subtractive_rng rnd; sl@0: if (range==0) return 0; sl@0: return rnd(range); sl@0: #endif sl@0: } sl@0: sl@0: // default base for random container sizes sl@0: unsigned random_base = 1000;