File indexing completed on 2026-04-09 07:49:20
0001 #include <map>
0002 #include "OPTICKS_LOG.hh"
0003 #include "SRand.hh"
0004
0005 int main(int argc, char** argv)
0006 {
0007 OPTICKS_LOG(argc, argv);
0008
0009 unsigned num_cat = 10 ;
0010 unsigned num_throw = 1000000 ;
0011
0012 LOG(info)
0013 << " num_cat " << num_cat
0014 << " num_throw " << num_throw
0015 ;
0016
0017 std::map<unsigned, unsigned> category_count ;
0018
0019 for(unsigned i=0 ; i < num_throw ; i++)
0020 {
0021 unsigned category = SRand::pick_random_category(num_cat);
0022 category_count[category] += 1 ;
0023 }
0024
0025 typedef std::map<unsigned, unsigned>::const_iterator IT ;
0026 for(IT it=category_count.begin() ; it != category_count.end() ; it++)
0027 {
0028 std::cout
0029 << std::setw(10) << it->first
0030 << " : "
0031 << std::setw(10) << it->second
0032 << std::endl
0033 ;
0034 }
0035
0036 return 0 ;
0037 }