CMS 3D CMS Logo

SmallWORMDict.h
Go to the documentation of this file.
1 #ifndef cond_SmallWORMDict_h
2 #define cond_SmallWORMDict_h
3 
5 
6 #include <vector>
7 #include <string>
8 #include <boost/iterator_adaptors.hpp>
9 #include <boost/iterator/transform_iterator.hpp>
10 #include <boost/iterator/counting_iterator.hpp>
11 
12 // Function for testing SmallWORMDict
13 namespace test {
14  namespace SmallWORMDict {
15  int test();
16  }
17 } // namespace test
18 
19 namespace cond {
20 
25  class SmallWORMDict {
26  friend int test::SmallWORMDict::test();
27 
28  public:
29  SmallWORMDict();
31 
32  struct Frame {
33  Frame() : b(nullptr) {}
34  Frame(char const* ib, unsigned int il, unsigned int iind) : b(ib), l(il), ind(iind) {}
35  char const* b;
36  unsigned int l;
37  unsigned int ind;
38  };
39 
40  struct IterHelp {
41  typedef Frame result_type;
42  IterHelp() : v(nullptr) {}
43  IterHelp(SmallWORMDict const& iv) : v(&iv) {}
44 
45  result_type const& operator()(int i) const {
46  int k = (0 == i) ? 0 : v->m_index[i - 1];
47  return frame(&v->m_data[k], v->m_index[i] - k, i);
48  }
49 
50  Frame const& frame(char const* b, unsigned int l, unsigned int ind) const {
51  f.b = b;
52  f.l = l;
53  f.ind = ind;
54  return f;
55  }
56 
57  private:
58  SmallWORMDict const* v;
59  mutable Frame f;
60  };
61 
62  friend struct IterHelp;
63 
64  typedef boost::transform_iterator<IterHelp, boost::counting_iterator<int> > const_iterator;
65 
67  return boost::make_transform_iterator(boost::counting_iterator<int>(0), IterHelp(*this));
68  }
69 
70  const_iterator end() const {
71  return boost::make_transform_iterator(boost::counting_iterator<int>(size()), IterHelp(*this));
72  }
73 
74  Frame operator[](int i) const {
75  int k = (0 == i) ? 0 : m_index[i - 1];
76  return Frame(&m_data[k], m_index[i] - k, i);
77  }
78 
79  const_iterator find(std::string const& s) const;
80 
81  const_iterator find(char const* s) const;
82 
83  // constructror from config
84  explicit SmallWORMDict(std::vector<std::string> const& idict);
85 
86  // find location of a word
87  size_t index(std::string const& s) const;
88 
89  size_t index(char const* s) const;
90 
91  size_t size() const;
92 
93  private:
94  std::vector<char> m_data;
95  std::vector<unsigned int> m_index;
96 
98  };
99 
100 } // namespace cond
101 
102 #endif
cond::SmallWORMDict::m_index
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:95
cond::SmallWORMDict::IterHelp::IterHelp
IterHelp(SmallWORMDict const &iv)
Definition: SmallWORMDict.h:43
mps_fire.i
i
Definition: mps_fire.py:428
cond::SmallWORMDict::~SmallWORMDict
~SmallWORMDict()
Definition: SmallWORMDict.cc:10
gpuVertexFinder::iv
int32_t *__restrict__ iv
Definition: gpuClusterTracksDBSCAN.h:42
COND_SERIALIZABLE
#define COND_SERIALIZABLE
Definition: Serializable.h:39
cond::SmallWORMDict::Frame::b
char const * b
Definition: SmallWORMDict.h:35
cond::SmallWORMDict::IterHelp
friend struct IterHelp
Definition: SmallWORMDict.h:62
cond::SmallWORMDict::operator[]
Frame operator[](int i) const
Definition: SmallWORMDict.h:74
cond::SmallWORMDict::IterHelp::frame
Frame const & frame(char const *b, unsigned int l, unsigned int ind) const
Definition: SmallWORMDict.h:50
cond::SmallWORMDict::const_iterator
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: SmallWORMDict.h:64
alignCSCRings.s
s
Definition: alignCSCRings.py:92
test
Definition: SmallWORMDict.h:13
cond::SmallWORMDict::IterHelp::operator()
result_type const & operator()(int i) const
Definition: SmallWORMDict.h:45
test::SmallWORMDict::test
int test()
cond::SmallWORMDict::begin
const_iterator begin() const
Definition: SmallWORMDict.h:66
dqmdumpme.k
k
Definition: dqmdumpme.py:60
b
double b
Definition: hdecay.h:118
pixelCPEforGPU::Frame
SOAFrame< float > Frame
Definition: pixelCPEforGPU.h:18
cond::SmallWORMDict::IterHelp::v
SmallWORMDict const * v
Definition: SmallWORMDict.h:58
cond
Definition: plugin.cc:23
cond::SmallWORMDict::end
const_iterator end() const
Definition: SmallWORMDict.h:70
cond::SmallWORMDict::Frame::Frame
Frame(char const *ib, unsigned int il, unsigned int iind)
Definition: SmallWORMDict.h:34
cond::SmallWORMDict::IterHelp
Definition: SmallWORMDict.h:40
cond::SmallWORMDict::m_data
std::vector< char > m_data
Definition: SmallWORMDict.h:94
cond::SmallWORMDict
Definition: SmallWORMDict.h:25
cond::SmallWORMDict::index
size_t index(std::string const &s) const
Definition: SmallWORMDict.cc:37
Serializable.h
cuy.ib
ib
Definition: cuy.py:661
cond::SmallWORMDict::find
const_iterator find(std::string const &s) const
Definition: SmallWORMDict.cc:41
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
cond::SmallWORMDict::IterHelp::result_type
Frame result_type
Definition: SmallWORMDict.h:41
cond::SmallWORMDict::Frame::ind
unsigned int ind
Definition: SmallWORMDict.h:37
cond::SmallWORMDict::SmallWORMDict
SmallWORMDict()
Definition: SmallWORMDict.cc:9
cond::SmallWORMDict::Frame::Frame
Frame()
Definition: SmallWORMDict.h:33
cond::SmallWORMDict::IterHelp::f
Frame f
Definition: SmallWORMDict.h:59
cond::SmallWORMDict::size
size_t size() const
Definition: SmallWORMDict.cc:51
cond::SmallWORMDict::IterHelp::IterHelp
IterHelp()
Definition: SmallWORMDict.h:42
cond::SmallWORMDict::Frame
Definition: SmallWORMDict.h:32
cond::SmallWORMDict::Frame::l
unsigned int l
Definition: SmallWORMDict.h:36