Back to home page

EIC code displayed by LXR

 
 

    


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

0001 /*
0002  * Copyright (c) 2019 Opticks Team. All Rights Reserved.
0003  *
0004  * This file is part of Opticks
0005  * (see https://bitbucket.org/simoncblyth/opticks).
0006  *
0007  * Licensed under the Apache License, Version 2.0 (the "License"); 
0008  * you may not use this file except in compliance with the License.  
0009  * You may obtain a copy of the License at
0010  *
0011  *   http://www.apache.org/licenses/LICENSE-2.0
0012  *
0013  * Unless required by applicable law or agreed to in writing, software 
0014  * distributed under the License is distributed on an "AS IS" BASIS, 
0015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  
0016  * See the License for the specific language governing permissions and 
0017  * limitations under the License.
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