File indexing completed on 2026-04-09 07:49:47
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #pragma once
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031 #include <map>
0032 #include <string>
0033 #include <vector>
0034 #include <algorithm>
0035 #include "SYSRAP_API_EXPORT.hh"
0036
0037 struct SYSRAP_API SSortKV
0038 {
0039 typedef std::pair<std::string, float> KV ;
0040 typedef std::vector<KV> VKV ;
0041
0042 SSortKV(bool descending_) : descending(descending_) {}
0043
0044 void add(const char* k, float v)
0045 {
0046 vkv.push_back(KV(k, v));
0047 }
0048 void sort()
0049 {
0050 std::sort(vkv.begin(), vkv.end(), *this );
0051 }
0052 void dump(const char* msg="SSortKV::dump") const ;
0053
0054 bool operator()( const KV& a, const KV& b) const
0055 {
0056 return descending ? a.second > b.second : a.second < b.second ;
0057 }
0058 unsigned getNum() const
0059 {
0060 return vkv.size();
0061 }
0062 const std::string& getKey(unsigned i) const
0063 {
0064 return vkv[i].first ;
0065 }
0066 float getVal(unsigned i) const
0067 {
0068 return vkv[i].second ;
0069 }
0070
0071 VKV vkv ;
0072 bool descending ;
0073
0074 };
0075