CMS 3D CMS Logo

SmallWORMDict.cc
Go to the documentation of this file.
2 #include <string>
3 #include <functional>
4 #include <numeric>
5 
6 namespace cond {
7  using namespace std::placeholders;
8 
11 
12  SmallWORMDict::SmallWORMDict(std::vector<std::string> const& idict)
13  : m_data(std::accumulate(idict.begin(), idict.end(), 0, [](int a, std::string b) { return a + b.size(); })),
14  m_index(idict.size(), 1) {
15  // sort (use index)
16  m_index[0] = 0;
17  std::partial_sum(m_index.begin(), m_index.end(), m_index.begin());
18  std::sort(m_index.begin(), m_index.end(), [&idict](unsigned int a, unsigned int b) {
19  return std::less<std::string>()(idict[a], idict[b]);
20  });
21 
22  //copy
23  std::vector<char>::iterator p = m_data.begin();
24  for (size_t j = 0; j < m_index.size(); j++) {
25  size_t i = m_index[j];
26  p = std::copy(idict[i].begin(), idict[i].end(), p);
27  m_index[j] = p - m_data.begin();
28  }
29  }
30 
31  struct LessFrame {
32  bool operator()(SmallWORMDict::Frame const& rh, SmallWORMDict::Frame const& lh) const {
33  return std::lexicographical_compare(rh.b, rh.b + rh.l, lh.b, lh.b + lh.l);
34  }
35  };
36 
37  size_t SmallWORMDict::index(std::string const& s) const { return (*find(s)).ind; }
38 
39  size_t SmallWORMDict::index(char const* s) const { return (*find(s)).ind; }
40 
42  Frame sp(&s[0], s.size(), 0);
43  return std::lower_bound(begin(), end(), sp, LessFrame());
44  }
45 
47  Frame sp(s, ::strlen(s), 0);
48  return std::lower_bound(begin(), end(), sp, LessFrame());
49  }
50 
51  size_t SmallWORMDict::size() const { return m_index.size(); }
52 
53 } // namespace cond
cond::SmallWORMDict::m_index
std::vector< unsigned int > m_index
Definition: SmallWORMDict.h:95
mps_fire.i
i
Definition: mps_fire.py:428
cond::SmallWORMDict::~SmallWORMDict
~SmallWORMDict()
Definition: SmallWORMDict.cc:10
cond::LessFrame
Definition: SmallWORMDict.cc:31
filterCSVwithJSON.copy
copy
Definition: filterCSVwithJSON.py:36
cond::SmallWORMDict::Frame::b
char const * b
Definition: SmallWORMDict.h:35
mathSSE::lh
bool int lh
Definition: SIMDVec.h:20
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
cond::SmallWORMDict::begin
const_iterator begin() const
Definition: SmallWORMDict.h:66
mps_fire.end
end
Definition: mps_fire.py:242
b
double b
Definition: hdecay.h:118
SmallWORMDict.h
cond
Definition: plugin.cc:23
pfDeepBoostedJetPreprocessParams_cfi.lower_bound
lower_bound
Definition: pfDeepBoostedJetPreprocessParams_cfi.py:15
a
double a
Definition: hdecay.h:119
cond::SmallWORMDict::end
const_iterator end() const
Definition: SmallWORMDict.h:70
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
cond::SmallWORMDict::index
size_t index(std::string const &s) const
Definition: SmallWORMDict.cc:37
createfilelist.int
int
Definition: createfilelist.py:10
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
std
Definition: JetResolutionObject.h:76
cond::LessFrame::operator()
bool operator()(SmallWORMDict::Frame const &rh, SmallWORMDict::Frame const &lh) const
Definition: SmallWORMDict.cc:32
cond::SmallWORMDict::SmallWORMDict
SmallWORMDict()
Definition: SmallWORMDict.cc:9
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
cond::SmallWORMDict::size
size_t size() const
Definition: SmallWORMDict.cc:51
cond::SmallWORMDict::Frame
Definition: SmallWORMDict.h:32
cond::SmallWORMDict::Frame::l
unsigned int l
Definition: SmallWORMDict.h:36