CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Enumerations | Functions
BitonicSort.h File Reference
#include <cstdint>
#include <vector>

Go to the source code of this file.

Enumerations

enum  sort_direction { up, down }
 

Functions

template<typename T >
void BitonicMerge (sort_direction aDir, typename std::vector< T >::iterator &aDataStart, typename std::vector< T >::iterator &aDataEnd)
 
template<typename T >
void BitonicSort (sort_direction aDir, typename std::vector< T >::iterator &aDataStart, typename std::vector< T >::iterator &aDataEnd)
 

Enumeration Type Documentation

Enumerator
up 
down 

Definition at line 7 of file BitonicSort.h.

7 { up, down };
Definition: BitonicSort.h:7

Function Documentation

template<typename T >
void BitonicMerge ( sort_direction  aDir,
typename std::vector< T >::iterator &  aDataStart,
typename std::vector< T >::iterator &  aDataEnd 
)

Definition at line 41 of file BitonicSort.h.

References std::swap(), and up.

43  {
44  uint32_t lSize(aDataEnd - aDataStart);
45  if (lSize > 1) {
46  uint32_t lPower2(1);
47  while (lPower2 < lSize)
48  lPower2 <<= 1;
49 
50  typename std::vector<T>::iterator lMidpoint(aDataStart + (lPower2 >> 1));
51  typename std::vector<T>::iterator lFirst(aDataStart);
52  typename std::vector<T>::iterator lSecond(lMidpoint);
53 
54  for (; lSecond != aDataEnd; ++lFirst, ++lSecond) {
55  if (((*lFirst) > (*lSecond)) == (aDir == up)) {
56  std::swap(*lFirst, *lSecond);
57  }
58  }
59 
60  BitonicMerge<T>(aDir, aDataStart, lMidpoint);
61  BitonicMerge<T>(aDir, lMidpoint, aDataEnd);
62  }
63 }
Definition: BitonicSort.h:7
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
template<typename T >
void BitonicSort ( sort_direction  aDir,
typename std::vector< T >::iterator &  aDataStart,
typename std::vector< T >::iterator &  aDataEnd 
)

Definition at line 22 of file BitonicSort.h.

References down, and up.

24  {
25  uint32_t lSize(aDataEnd - aDataStart);
26  if (lSize > 1) {
27  typename std::vector<T>::iterator lMidpoint(aDataStart + (lSize >> 1));
28  if (aDir == down) {
29  BitonicSort<T>(up, aDataStart, lMidpoint);
30  BitonicSort<T>(down, lMidpoint, aDataEnd);
31  } else {
32  BitonicSort<T>(down, aDataStart, lMidpoint);
33  BitonicSort<T>(up, lMidpoint, aDataEnd);
34  }
35  BitonicMerge<T>(aDir, aDataStart, aDataEnd);
36  }
37 }
Definition: BitonicSort.h:7