CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros 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 BitonicCompare (sort_direction aDir, typename std::vector< T >::iterator &aDataStart, typename std::vector< T >::iterator &aDataEnd)
 
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 8 of file BitonicSort.h.

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

Function Documentation

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

Definition at line 73 of file BitonicSort.h.

References down, std::swap(), and up.

77 {
78 
79  uint32_t lSize( aDataEnd - aDataStart );
80 
81  typename std::vector<T>::iterator lFirst( aDataStart );
82  typename std::vector<T>::iterator lSecond( aDataStart+(lSize>>1) );
83 
84  for( ; lSecond != aDataEnd ; ++lFirst , ++lSecond ){
85  bool lComp( *lFirst > *lSecond );
86  if( ( lComp && (aDir == up) ) || ( !lComp && (aDir == down) ) ) {
87  std::swap( *lFirst , *lSecond );
88  }
89  }
90 
91 }
Definition: BitonicSort.h:8
void swap(edm::DataFrameContainer &lhs, edm::DataFrameContainer &rhs)
template<typename T >
void BitonicMerge ( sort_direction  aDir,
typename std::vector< T >::iterator &  aDataStart,
typename std::vector< T >::iterator &  aDataEnd 
)

Definition at line 55 of file BitonicSort.h.

59 {
60  uint32_t lSize( aDataEnd - aDataStart );
61 
62  if( lSize > 1 ){
63  BitonicCompare<T> ( aDir, aDataStart , aDataEnd );
64  typename std::vector<T>::iterator lMidpoint( aDataStart+(lSize>>1) );
65  BitonicMerge<T> ( aDir, aDataStart , lMidpoint );
66  BitonicMerge<T> ( aDir, lMidpoint , aDataEnd );
67  }
68 }
template<typename T >
void BitonicSort ( sort_direction  aDir,
typename std::vector< T >::iterator &  aDataStart,
typename std::vector< T >::iterator &  aDataEnd 
)

Definition at line 37 of file BitonicSort.h.

References down, and up.

41 {
42  uint32_t lSize( aDataEnd - aDataStart );
43 
44  if( lSize > 1 ){
45  typename std::vector<T>::iterator lMidpoint( aDataStart+(lSize>>1) );
46  BitonicSort<T> ( up, aDataStart , lMidpoint );
47  BitonicSort<T> ( down, lMidpoint , aDataEnd );
48  BitonicMerge<T> (aDir, aDataStart , aDataEnd );
49  }
50 
51 }
Definition: BitonicSort.h:8