In this tutorial we learn how elements of an RVec can be easily sorted and selected.
{
std::sort(
v2.begin(),
v2.end());
std::cout <<
"Sort vector " <<
v1 <<
": " <<
v2 << std::endl;
std::cout <<
"Sort vector " <<
v1 <<
": " <<
v3 << std::endl;
std::cout <<
"Reverse vector " <<
v1 <<
": " <<
v4 << std::endl;
std::cout <<
"Indices that sort the vector " <<
v1 <<
": " << i << std::endl;
std::cout << "Sort vector " << v5 << " respective to the previously"
<< " determined indices: " << v6 << std::endl;
std::cout <<
"Take the two first and last elements of vector " <<
v1
<< ": " << v7 << ", " << v8 << std::endl;
std::cout <<
"Sort the vector " <<
v1 <<
", take the two last elements and "
<< "reverse the selection: " << v9 << std::endl;
}
RVec< T > Reverse(const RVec< T > &v)
Return copy of reversed vector.
RVec< T > Take(const RVec< T > &v, const RVec< typename RVec< T >::size_type > &i)
Return elements of a vector at given indices.
void Sort(Index n, const Element *a, Index *index, Bool_t down=kTRUE)
Sort vector { 6, 4, 5 }: { 4, 5, 6 }
Sort vector { 6, 4, 5 }: { 4, 5, 6 }
Reverse vector { 6, 4, 5 }: { 5, 4, 6 }
Indices that sort the vector { 6, 4, 5 }: { 1, 2, 0 }
Sort vector { 9, 7, 8 } respective to the previously determined indices: { 7, 8, 9 }
Take the two first and last elements of vector { 6, 4, 5 }: { 6, 4 }, { 4, 5 }
Sort the vector { 6, 4, 5 }, take the two last elements and reverse the selection: { 6, 5 }
- Date
- August 2018
- Author
- Stefan Wunsch
Definition in file vo004_SortAndSelect.C.