Back to home page

EIC code displayed by LXR

 
 

    


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

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 <algorithm>
0021 #include <iostream>
0022 
0023 #include "SPairVec.hh"
0024 #include "SLOG.hh"
0025 
0026 
0027 template <typename K, typename V>
0028 SPairVec<K,V>::SPairVec( LPKV& lpkv, bool ascending )
0029    :
0030    _lpkv(lpkv), 
0031    _ascending(ascending)
0032 {
0033 }
0034 
0035 template <typename K, typename V>
0036 bool SPairVec<K,V>::operator()(const PKV& a, const PKV& b)
0037 {
0038     return _ascending ? a.second < b.second : a.second > b.second ; 
0039 }
0040 
0041 template <typename K, typename V>
0042 void SPairVec<K,V>::sort()
0043 {
0044     std::sort( _lpkv.begin(), _lpkv.end(), *this );
0045 }
0046 
0047 
0048 template <typename K, typename V>
0049 void SPairVec<K,V>::dump(const char* msg) const 
0050 {
0051     LOG(info) << msg << " size " << _lpkv.size() ; 
0052     for(unsigned i=0 ; i < _lpkv.size() ; i++)
0053     {
0054         std::cerr 
0055             << " " << _lpkv[i].first 
0056             << " " << _lpkv[i].second
0057             << std::endl 
0058             ;
0059     }
0060 }
0061 
0062 
0063 
0064 template struct SPairVec<std::string, unsigned>;
0065 
0066