File indexing completed on 2026-04-09 07:49:39
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <cassert>
0021 #include <cmath>
0022 #include <iostream>
0023
0024 #include "SMap.hh"
0025 #include "SLOG.hh"
0026
0027
0028 template <typename K, typename V>
0029 unsigned SMap<K,V>::ValueCount(const std::map<K,V>& m, V value)
0030 {
0031 unsigned count(0);
0032 for(typename MKV::const_iterator it=m.begin() ; it != m.end() ; it++)
0033 {
0034 V v = it->second ;
0035 if( v == value ) count++ ;
0036 }
0037 return count ;
0038 }
0039
0040
0041 template <typename K, typename V>
0042 void SMap<K,V>::FindKeys(const std::map<K,V>& m, std::vector<K>& keys, V value, bool dump)
0043 {
0044 if(dump)
0045 {
0046 LOG(info) << " value " << std::setw(32) << std::hex << value << std::dec ;
0047 }
0048
0049 for(typename MKV::const_iterator it=m.begin() ; it != m.end() ; it++)
0050 {
0051 K k = it->first ;
0052 V v = it->second ;
0053 bool match = v == value ;
0054
0055 if(dump)
0056 {
0057 LOG(info)
0058 << " k " << k
0059 << " v " << std::setw(32) << std::hex << v << std::dec
0060 << " match " << ( match ? "Y" : "N" )
0061 << " keys.size() " << keys.size()
0062 ;
0063 }
0064
0065 if( match ) keys.push_back(k) ;
0066 }
0067 }
0068
0069
0070
0071
0072
0073
0074
0075 template struct SMap<std::string, unsigned long long>;
0076
0077