File indexing completed on 2026-04-09 07:49:41
0001 #include <vector>
0002 #include <string>
0003 #include <iostream>
0004 #include <iomanip>
0005 #include <algorithm>
0006
0007 #include "SYSRAP_API_EXPORT.hh"
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 template <typename T>
0021 struct SYSRAP_API SNameVec
0022 {
0023 static void Dump(const std::vector<T*>& a );
0024 static void Sort( std::vector<T*>& a, bool reverse );
0025 };
0026
0027 template <typename T>
0028 struct SYSRAP_API SNameVecOrder
0029 {
0030 SNameVecOrder(bool reverse_) : reverse(reverse_) {}
0031
0032 bool operator() (const T* a, const T* b) const
0033 {
0034 const std::string an = a->GetName() ;
0035 const std::string bn = b->GetName() ;
0036 bool cmp = an < bn ;
0037 return reverse ? !cmp : cmp ;
0038 }
0039 bool reverse ;
0040 };
0041
0042
0043 template <typename T>
0044 void SNameVec<T>::Dump( const std::vector<T*>& a )
0045 {
0046 for(unsigned i=0 ; i < a.size() ; i++) std::cout << std::setw(10) << a[i]->GetName() << std::endl ;
0047 }
0048
0049 template <typename T>
0050 void SNameVec<T>::Sort( std::vector<T*>& a, bool reverse)
0051 {
0052 SNameVecOrder<T> order(reverse) ;
0053 std::sort( a.begin(), a.end(), order );
0054 }
0055
0056