CMS 3D CMS Logo

DataFrameContainer.cc
Go to the documentation of this file.
2 
3 #include <boost/iterator/permutation_iterator.hpp>
4 
5 #include <algorithm>
6 #include <numeric>
7 #include <cstring>
8 
9 namespace edm {
10  namespace {
11  struct TypeCompare {
12  typedef DataFrameContainer::id_type id_type;
13  std::vector<id_type> const& ids_;
14  TypeCompare(std::vector<id_type> const& iType) : ids_(iType) {}
15  bool operator()(id_type const& iLHS, id_type const& iRHS) const { return ids_[iLHS] < ids_[iRHS]; }
16  };
17  } // namespace
18 
20  if (size() < 2)
21  return;
22  std::vector<int> indices(size(), 1);
23  indices[0] = 0;
24  std::partial_sum(indices.begin(), indices.end(), indices.begin());
25  std::sort(indices.begin(), indices.end(), TypeCompare(m_ids));
26  {
27  IdContainer tmp(m_ids.size());
28  std::copy(boost::make_permutation_iterator(m_ids.begin(), indices.begin()),
29  boost::make_permutation_iterator(m_ids.end(), indices.end()),
30  tmp.begin());
31  tmp.swap(m_ids);
32  }
33  {
34  // std::transform(indices.begin(),indices.end(),indices.begin(),
35  // std::bind(std::multiplies<int>(),m_stride,std::placeholders::_1));
36  DataContainer tmp(m_data.size());
37  size_type s = m_stride * sizeof(data_type);
38  for (size_type j = 0, i = 0; i != indices.size(); ++i, j += m_stride)
39  ::memcpy(&tmp[j], &m_data[indices[i] * m_stride], s);
40  tmp.swap(m_data);
41  }
42  }
43 
44 } // namespace edm
std::vector< data_type > DataContainer
HLT enums.
std::vector< id_type > IdContainer
tmp
align.sh
Definition: createJobs.py:716