Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-03-17 10:46:38

0001 #include "CondFormats/Common/interface/SmallWORMDict.h"
0002 
0003 #include <iostream>
0004 
0005 namespace test {
0006   namespace SmallWORMDict {
0007     int test() {
0008       std::vector<std::string> dict;
0009       size_t tot = 0;
0010       dict.push_back("Sneezy");
0011       tot += dict.back().size();
0012       dict.push_back("Sleepy");
0013       tot += dict.back().size();
0014       dict.push_back("Dopey");
0015       tot += dict.back().size();
0016       dict.push_back("Doc");
0017       tot += dict.back().size();
0018       dict.push_back("Happy");
0019       tot += dict.back().size();
0020       dict.push_back("Bashful");
0021       tot += dict.back().size();
0022       dict.push_back("Grumpy");
0023       tot += dict.back().size();
0024 
0025       cond::SmallWORMDict worm(dict);
0026 
0027       std::cout << dict.size() << " " << worm.m_index.size() << std::endl;
0028       std::cout << tot << " " << worm.m_data.size() << std::endl;
0029       std::copy(worm.m_index.begin(), worm.m_index.end(), std::ostream_iterator<int>(std::cout, " "));
0030       std::cout << std::endl;
0031       std::copy(worm.m_data.begin(), worm.m_data.end(), std::ostream_iterator<char>(std::cout, ""));
0032       std::cout << std::endl;
0033 
0034       cond::SmallWORMDict::Frame f = worm[2];
0035       std::copy(f.b, f.b + f.l, std::ostream_iterator<char>(std::cout, ""));
0036       std::cout << std::endl;
0037 
0038       int i = worm.index("Doc");
0039       f = worm[i];
0040       std::copy(f.b, f.b + f.l, std::ostream_iterator<char>(std::cout, ""));
0041       std::cout << " at " << i << std::endl;
0042 
0043       f = *worm.find("Sleepy");
0044       std::copy(f.b, f.b + f.l, std::ostream_iterator<char>(std::cout, ""));
0045       std::cout << " at " << f.ind << std::endl;
0046 
0047       return 0;
0048     }
0049   }  // namespace SmallWORMDict
0050 }  // namespace test
0051 
0052 int main() { return test::SmallWORMDict::test(); }