Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // om-;TEST=SNameVecTest om-t 
0002 
0003 #include <cstring>
0004 #include "SNameVec.hh"
0005 #include "OPTICKS_LOG.hh"
0006 
0007 struct Demo
0008 {
0009     Demo(const char* name_) :  name(strdup(name_)) {} 
0010     const char* GetName() const ; 
0011     const char* name ; 
0012 };
0013 
0014 const char* Demo::GetName() const 
0015 {
0016     return name ; 
0017 }
0018 
0019 template struct SNameVec<Demo> ; 
0020 
0021 void test_Dump()
0022 {
0023     std::vector<Demo*> a ; 
0024     a.push_back(new Demo("red")); 
0025     a.push_back(new Demo("green")); 
0026     a.push_back(new Demo("blue")); 
0027     a.push_back(new Demo("cyan")); 
0028     a.push_back(new Demo("magenta")); 
0029     a.push_back(new Demo("yellow")); 
0030     SNameVec<Demo>::Dump(a); 
0031 }
0032 
0033 void test_Sort()
0034 {
0035     std::vector<Demo*> a ; 
0036     a.push_back(new Demo("red")); 
0037     a.push_back(new Demo("green")); 
0038     a.push_back(new Demo("blue")); 
0039     a.push_back(new Demo("cyan")); 
0040     a.push_back(new Demo("magenta")); 
0041     a.push_back(new Demo("yellow")); 
0042 
0043     LOG(info) << " Dump asis " ;  
0044     SNameVec<Demo>::Dump(a); 
0045 
0046     LOG(info) << " Sort " ;  
0047     SNameVec<Demo>::Sort(a, false);
0048     SNameVec<Demo>::Dump(a); 
0049 
0050     LOG(info) << " Sort reversed " ;  
0051     SNameVec<Demo>::Sort(a, true); 
0052     SNameVec<Demo>::Dump(a); 
0053 }
0054 
0055 int main(int argc, char** argv)
0056 {
0057     OPTICKS_LOG(argc, argv);
0058 
0059     //test_Dump(); 
0060     test_Sort(); 
0061 
0062     return 0 ;
0063 }
0064 
0065 // om-;TEST=SNameVecTest om-t