11 #ifdef PANZER_HAVE_EPETRA_STACK
13 #ifndef __Panzer_STK_Utilities_hpp__
14 #define __Panzer_STK_Utilities_hpp__
18 #include "Epetra_Vector.h"
19 #include "Epetra_MultiVector.h"
25 namespace panzer_stk {
46 template <
typename RAContainer,
class Compare>
47 void sorted_permutation(
const RAContainer & cont,std::vector<std::size_t> & permutation,
const Compare & comp);
55 template <
typename RAContainer>
56 void sorted_permutation(
const RAContainer & cont,std::vector<std::size_t> & permutation);
60 namespace panzer_stk {
62 template <
typename RAContainer,
typename Compare>
64 PermFunctor(
const RAContainer & cont,
const Compare & comp)
65 : compare(comp), values(cont) {}
66 PermFunctor(
const PermFunctor & p)
67 : compare(p.compare), values(p.values) {}
69 bool operator()(std::size_t a,std::size_t b)
const
70 {
return compare(values[a],values[b]); }
73 const Compare & compare;
74 const RAContainer & values;
79 template <
typename RAContainer>
80 void sorted_permutation(
const RAContainer & cont,std::vector<std::size_t> & permutation)
82 std::less<typename RAContainer::value_type> comp;
83 sorted_permutation(cont,permutation,comp);
86 template <
typename RAContainer,
class Compare>
87 void sorted_permutation(
const RAContainer & cont,std::vector<std::size_t> & permutation,
const Compare & comp)
89 PermFunctor<RAContainer,Compare> pf(cont,comp);
91 permutation.resize(cont.size());
92 for(std::size_t i=0;i<cont.size();i++)
95 std::sort(permutation.begin(),permutation.end(),pf);
102 #endif // PANZER_HAVE_EPETRA_STACK