test
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 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 BitonicMerge ( sort_direction  aDir,
typename std::vector< T >::iterator &  aDataStart,
typename std::vector< T >::iterator &  aDataEnd 
)

Definition at line 48 of file BitonicSort.h.

References std::swap(), and up.

52 {
53  uint32_t lSize( aDataEnd - aDataStart );
54  if( lSize > 1 ){
55 
56  uint32_t lPower2(1);
57  while (lPower2<lSize) lPower2<<=1;
58 
59  typename std::vector<T>::iterator lMidpoint( aDataStart + (lPower2>>1) );
60  typename std::vector<T>::iterator lFirst( aDataStart );
61  typename std::vector<T>::iterator lSecond( lMidpoint );
62 
63  for( ; lSecond != aDataEnd ; ++lFirst , ++lSecond ){
64  if( ( (*lFirst) > (*lSecond) ) == (aDir == up) ) {
65  std::swap( *lFirst , *lSecond );
66  }
67  }
68 
69  BitonicMerge<T> ( aDir, aDataStart , lMidpoint );
70  BitonicMerge<T> ( aDir, lMidpoint , aDataEnd );
71  }
72 }
Definition: BitonicSort.h:8
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 26 of file BitonicSort.h.

References down, and up.

30 {
31  uint32_t lSize( aDataEnd - aDataStart );
32  if( lSize > 1 ){
33  typename std::vector<T>::iterator lMidpoint( aDataStart+(lSize>>1) );
34  if ( aDir == down )
35  {
36  BitonicSort<T> ( up, aDataStart , lMidpoint );
37  BitonicSort<T> ( down, lMidpoint , aDataEnd );
38  }else{
39  BitonicSort<T> ( down, aDataStart , lMidpoint );
40  BitonicSort<T> ( up, lMidpoint , aDataEnd );
41  }
42  BitonicMerge<T> (aDir, aDataStart , aDataEnd );
43  }
44 }
Definition: BitonicSort.h:8