Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:49:31

0001 #include "SCount.hh"
0002 
0003 #include <iomanip>
0004 #include <sstream>
0005 
0006 void SCount::add(int idx)
0007 {
0008     if( mii.count(idx) == 0 ) mii[idx] = 0 ; 
0009     mii[idx] += 1 ;   
0010 }
0011 
0012 /**
0013 SCount::is_all
0014 ---------------
0015 
0016 Returns true when all the counts match the argument provides
0017 **/
0018 
0019 bool SCount::is_all(int count) const
0020 {
0021     typedef std::map<int,int>::const_iterator IT ; 
0022     for(IT it=mii.begin() ; it != mii.end() ; it++ ) if(it->second != count) return false ;
0023     return true ;     
0024 }
0025 
0026 
0027 std::string SCount::desc() const 
0028 {
0029     std::stringstream ss ; 
0030     typedef std::map<int,int>::const_iterator IT ; 
0031     bool all_same_count = false ; 
0032     int count = -1 ; 
0033 
0034     for(IT it=mii.begin() ; it != mii.end() ; it++ )
0035     {   
0036          int idx = it->first ; 
0037 
0038          count = it->second ; 
0039          all_same_count = is_all(count); 
0040 
0041          if(!all_same_count)
0042          {
0043              ss  
0044                 << " " 
0045                 << idx
0046                 << ":" 
0047                 << count
0048                 ;   
0049          }
0050          else
0051          {
0052             ss << " " << idx ;   
0053          }
0054     }   
0055 
0056     if( all_same_count ) ss << " all_same_count " << count ; 
0057     std::string s = ss.str(); 
0058     return s ; 
0059 }
0060 
0061