Loading [MathJax]/extensions/TeX/AMSsymbols.js

DUNE-ACFEM (unstable)

sequencesort.hh
1#ifndef __DUNE_ACFEM_MPL_SEQUENCESORT_HH__
2#define __DUNE_ACFEM_MPL_SEQUENCESORT_HH__
3
4#include "generators.hh"
5#include "typetuplesort.hh"
6
7namespace Dune::ACFem::MPL {
8
9 namespace {
10
11 template<std::size_t I0, std::size_t I1>
12 struct IndexPair
13 {
14 static constexpr std::size_t i0 = I0;
15 static constexpr std::size_t i1 = I1;
16 };
17
18 template<class Tuple>
19 struct UnpackSortData;
20
21 template<std::size_t... I, std::size_t... P>
22 struct UnpackSortData<TypeTuple<IndexPair<I, P>...> >
23 {
24 using Result = IndexSequence<I...>;
25 using Permutation = IndexSequence<P...>;
26 };
27
28 }
29
30 template<class Seq, template<std::size_t, std::size_t> class DoSwap, class Permutation = MakeSequenceFor<Seq> >
31 struct SortSequence;
32
33 template<std::size_t... I, std::size_t... P, template<std::size_t, std::size_t> class DoSwap>
34 struct SortSequence<IndexSequence<I...>, DoSwap, IndexSequence<P...> >
35 {
36 template<class A, class B>
37 using Swap = DoSwap<A::i0, B::i0>;
38
39 using SortData = TypeTuple<IndexPair<I, P>...>;
40 using SortInfo = MergeSort<SortData, Swap>;
41 using Result = typename UnpackSortData<SortInfo>::Result;
42 using Permutation = typename UnpackSortData<SortInfo>::Permutation;
43 };
44
45 template<class Seq, template<std::size_t, std::size_t> class DoSwap>
46 struct IsSorted;
47
48 template<std::size_t... I, template<std::size_t, std::size_t> class DoSwap>
49 struct IsSorted<IndexSequence<I...>, DoSwap>
50 {
51 template<class A, class B>
52 using Swap = DoSwap<A::value, B::value>;
53
54 static constexpr bool value = IsSortedV<TypeTuple<IndexConstant<I>...>, Swap>;
55 };
56
57} // Dune::ACFem::MPL
58
59#endif // __DUNE_ACFEM_MPL_SEQUENCESORT_HH__
Sequence< std::size_t, V... > IndexSequence
Sequence of std::size_t values.
Definition: types.hh:64
Form a sub-sequence with the values at the positions NOT given in Indices.
Definition: conditional.hh:8
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Mar 12, 23:28, 2025)