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 }
18 
19 namespace cond {
20 
25  class SmallWORMDict {
26  friend int test::SmallWORMDict::test();
27 
28  public:
29  SmallWORMDict();
30  ~SmallWORMDict();
31 
32  struct Frame {
33  Frame(): b(nullptr){}
34  Frame(char const * ib,
35  unsigned int il,
36  unsigned int iind) :
37  b(ib),l(il),ind(iind){}
38  char const * b;
39  unsigned int l;
40  unsigned int ind;
41  };
42 
43  struct IterHelp {
44  typedef Frame result_type;
46  IterHelp(SmallWORMDict const & iv) : v(&iv){}
47 
48  result_type const & operator()(int i) const {
49  int k = (0==i) ? 0 : v->m_index[i-1];
50  return frame(&v->m_data[k], v->m_index[i]-k, i);
51  }
52 
53  Frame const & frame(char const * b,
54  unsigned int l,
55  unsigned int ind) const {
56  f.b = b; f.l=l; f.ind=ind;
57  return f;
58  }
59 
60  private:
61  SmallWORMDict const * v;
62  mutable Frame f;
63  };
64 
65  friend struct IterHelp;
66 
67  typedef boost::transform_iterator<IterHelp,boost::counting_iterator<int> > const_iterator;
68 
69 
70  const_iterator begin() const {
71  return boost::make_transform_iterator(boost::counting_iterator<int>(0),
72  IterHelp(*this));
73  }
74 
75  const_iterator end() const {
76  return boost::make_transform_iterator(boost::counting_iterator<int>(size()),
77  IterHelp(*this));
78  }
79 
80  Frame operator[](int i) const {
81  int k = (0==i) ? 0 : m_index[i-1];
82  return Frame(&m_data[k], m_index[i]-k, i);
83  }
84 
85  const_iterator find(std::string const & s) const;
86 
87  const_iterator find(char const * s) const;
88 
89  // constructror from config
90  explicit SmallWORMDict(std::vector<std::string> const & idict);
91 
92  // find location of a word
93  size_t index(std::string const & s) const;
94 
95  size_t index(char const * s) const;
96 
97  size_t size() const;
98 
99  private:
100  std::vector<char> m_data;
101  std::vector<unsigned int> m_index;
102 
104 };
105 
106 
107 }
108 
109 #endif
size
Write out results.
SmallWORMDict const * v
Definition: SmallWORMDict.h:61
const_iterator end() const
Definition: SmallWORMDict.h:75
std::vector< unsigned int > m_index
const_iterator begin() const
Definition: SmallWORMDict.h:70
result_type const & operator()(int i) const
Definition: SmallWORMDict.h:48
Frame operator[](int i) const
Definition: SmallWORMDict.h:80
#define nullptr
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
Frame const & frame(char const *b, unsigned int l, unsigned int ind) const
Definition: SmallWORMDict.h:53
std::vector< char > m_data
boost::transform_iterator< IterHelp, boost::counting_iterator< int > > const_iterator
Definition: SmallWORMDict.h:67
double f[11][100]
int k[5][pyjets_maxn]
IterHelp(SmallWORMDict const &iv)
Definition: SmallWORMDict.h:46
double b
Definition: hdecay.h:120
#define COND_SERIALIZABLE
Definition: Serializable.h:38
Definition: plugin.cc:24
Frame(char const *ib, unsigned int il, unsigned int iind)
Definition: SmallWORMDict.h:34
ib
Definition: cuy.py:662