Panzer
Version of the Day
Toggle main menu visibility
Loading...
Searching...
No Matches
core
src
Panzer_UtilityAlgs.cpp
Go to the documentation of this file.
1
#include "
Panzer_UtilityAlgs.hpp
"
2
3
namespace
panzer
{
4
5
void
reorder
(std::vector<int> & order,std::function<
void
(
int
,
int
)> swapper)
6
{
7
// each entry has to be sorted
8
for
(
int
i=0;i<static_cast<int>(order.size());i++) {
9
10
// a, b, c
11
// 2, 0, 1
12
13
// here we are following a linked list until
14
// the entry is correct
15
while
(order[i]!=i) {
16
int
nearIndex = order[i];
// 2 : 1
17
int
farIndex = order[nearIndex];
// 1 : 0
18
19
// handle the user defined swap of indices
20
swapper(nearIndex,farIndex);
// a, c, b : c, a, b
21
22
order[order[i]] = nearIndex;
//
23
order[i] = farIndex;
// 1, 0, 2 : 0, 1, 2
24
}
25
}
26
27
// at the end of this, order vector will be sorted
28
}
29
30
}
// end namespace panzer
Panzer_UtilityAlgs.hpp
panzer
Computes .
Definition
Panzer_BasisValues_Evaluator_decl.hpp:54
panzer::reorder
void reorder(std::vector< int > &order, std::function< void(int, int)> swapper)
Using a functor, reorder an array using a order vector.
Definition
Panzer_UtilityAlgs.cpp:5
Generated by
1.17.0