File indexing completed on 2026-04-09 07:49:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
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