CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
AccumulatingSort< T > Class Template Reference

#include <AccumulatingSort.h>

Public Member Functions

 AccumulatingSort (const uint32_t &aSize)
 
void Merge (const std::vector< T > &aInput, std::vector< T > &aOutput)
 

Private Member Functions

void AccumulatorUnit (const std::list< T > &aInput, T &aAcc, std::list< T > &aTail)
 

Private Attributes

uint32_t mSize
 
std::vector< std::list< T > > mSortArrays
 

Detailed Description

template<typename T>
class AccumulatingSort< T >

Definition at line 7 of file AccumulatingSort.h.

Constructor & Destructor Documentation

template<typename T>
AccumulatingSort< T >::AccumulatingSort ( const uint32_t &  aSize)
inline

Definition at line 36 of file AccumulatingSort.h.

36  : mSortArrays( aSize+1 , std::list < T >( aSize ) ), mSize( aSize )
37  {}
std::vector< std::list< T > > mSortArrays

Member Function Documentation

template<typename T>
void AccumulatingSort< T >::AccumulatorUnit ( const std::list< T > &  aInput,
T aAcc,
std::list< T > &  aTail 
)
inlineprivate

Definition at line 15 of file AccumulatingSort.h.

Referenced by AccumulatingSort< T >::Merge().

16  {
17  aTail.clear();
18 
19  bool lAccInserted( false );
20 
21  for( typename std::list< T >::const_iterator lIt( aInput.begin() ) ; lIt != aInput.end() ; ++lIt )
22  {
23  if ( !lAccInserted and !( *lIt > aAcc ) ) // Accumulator greater than or equal to new entry and not previously inserted -> Reinsert accumulator
24  {
25  aTail.push_back( aAcc );
26  lAccInserted = true;
27  }
28  aTail.push_back( *lIt );
29  }
30 
31  aAcc = *aTail.begin();
32  aTail.erase( aTail.begin() );
33  }
template<typename T>
void AccumulatingSort< T >::Merge ( const std::vector< T > &  aInput,
std::vector< T > &  aOutput 
)
inline

Definition at line 39 of file AccumulatingSort.h.

References AccumulatingSort< T >::AccumulatorUnit(), begin, mps_fire::i, and AccumulatingSort< T >::mSize.

Referenced by l1t::Stage2Layer2JetAlgorithmFirmwareImp1::accuSort(), l1t::Stage2Layer2TauAlgorithmFirmwareImp1::dosorting(), and l1t::Stage2Layer2EGammaAlgorithmFirmwareImp1::processEvent().

40  {
41  aOutput.resize( mSize );
42 
43  mSortArrays[0].clear();
44  mSortArrays[0].insert( mSortArrays[0].begin() , aInput.begin() , aInput.end() );
45 
46  for( uint32_t i(0) ; i!=mSize ; ++i ) AccumulatorUnit( mSortArrays[ i ] , aOutput[ i ] , mSortArrays[ i+1 ] );
47  }
std::vector< std::list< T > > mSortArrays
void AccumulatorUnit(const std::list< T > &aInput, T &aAcc, std::list< T > &aTail)
#define begin
Definition: vmac.h:30

Member Data Documentation

template<typename T>
uint32_t AccumulatingSort< T >::mSize
private

Definition at line 12 of file AccumulatingSort.h.

Referenced by AccumulatingSort< T >::Merge().

template<typename T>
std::vector< std::list < T > > AccumulatingSort< T >::mSortArrays
private

Definition at line 11 of file AccumulatingSort.h.