TMath Namespace Reference

Functions

template<typename Element , typename Index >
void Sort (Index n, const Element *a, Index *index, bool down=true)
template<typename Iterator , typename IndexIterator >
void SortItr (Iterator first, Iterator last, IndexIterator index, bool down=true)

Function Documentation

template<typename Element , typename Index >
void TMath::Sort ( Index  n,
const Element *  a,
Index *  index,
bool  down = true 
) [inline]

Definition at line 136 of file cf2rr.cc.

Referenced by BFLWingedEdge::AddAvailableEdgeID(), BFLWingedEdge::AddAvailableVtxID(), OscProb::PMNS_Base::AvgProbLoE(), NuAnalysis::CreateTSpline3(), AlgTrackSR::FindStripsInTrack(), and PlexSEIdAltL::KeepTopWeights().

00137 {
00138    // Sort the n elements of the  array a of generic templated type Element.
00139    // In output the array index of type Index contains the indices of 
00140    // the sorted array.
00141    // If down is false sort in increasing order (default is decreasing order).
00142 
00143    // NOTE that the array index must be created with a length >= n
00144    // before calling this function.
00145    // NOTE also that the size type for n must be the same type used 
00146    // for the index array
00147    // (templated type Index)
00148 
00149    for(Index i = 0; i < n; i++) { index[i] = i; }
00150    if ( down )
00151       std::sort(index, index + n, CompareDesc<const Element*>(a) );
00152    else
00153       std::sort(index, index + n, CompareAsc<const Element*>(a) );
00154 }

template<typename Iterator , typename IndexIterator >
void TMath::SortItr ( Iterator  first,
Iterator  last,
IndexIterator  index,
bool  down = true 
) [inline]

Definition at line 109 of file cf2rr.cc.

00111 {
00112    // Sort the n1 elements of the Short_t array defined by its
00113    // iterators.  In output the array index contains the indices of
00114    // the sorted array.  If down is false sort in increasing order
00115    // (default is decreasing order).
00116 
00117    // NOTE that the array index must be created with a length bigger
00118    // or equal than the main array before calling this function.
00119 
00120    int i = 0;
00121 
00122    IndexIterator cindex = index;
00123    for ( Iterator cfirst = first; cfirst != last; ++cfirst )
00124    {
00125       *cindex = i++;
00126       ++cindex;
00127    }
00128 
00129    if ( down )
00130       std::sort(index, cindex, CompareDesc<Iterator>(first) );
00131    else
00132       std::sort(index, cindex, CompareAsc<Iterator>(first) );
00133 }


Generated on 16 Apr 2018 for loon by  doxygen 1.6.1