CoMMA 1.3.2
A geometric agglomerator for unstructured meshes
Loading...
Searching...
No Matches
Priority_Pair.h
Go to the documentation of this file.
1#ifndef COMMA_PROJECT_PRIORITY_PAIR_H
2#define COMMA_PROJECT_PRIORITY_PAIR_H
3
4/*
5 * CoMMA
6 *
7 * Copyright © 2024 ONERA
8 *
9 * Authors: Nicolas Lantos, Alberto Remigi, and Riccardo Milani
10 * Contributors: Karim Anemiche
11 *
12 * This Source Code Form is subject to the terms of the Mozilla Public
13 * License, v. 2.0. If a copy of the MPL was not distributed with this
14 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
15 */
16
17#include <utility>
18
19namespace comma {
20
29template<typename A, typename B>
31private:
33 std::pair<A, B> _p;
34
35public:
37 Priority_Pair() = default;
38 ;
39
44 Priority_Pair(const A &a, const B &b) :
45 _p(a, b){};
46
48 ~Priority_Pair() = default;
49 ;
50
54 // We accept to have a copy passed
55 A first() const { return _p.first; }
56
60 B second() const { return _p.second; }
61
69 inline friend bool operator<(const Priority_Pair &a, const Priority_Pair &b) {
70 if (a._p.first > b._p.first) return true;
71 if (a._p.first < b._p.first) return false;
72 /* a._p.first == b._p.first */
73 return a._p.second < b._p.second;
74 }
75
81 inline friend bool operator==(
82 const Priority_Pair &a, const Priority_Pair &b
83 ) {
84 return (a._p.first == b._p.first) && (a._p.second == b._p.second);
85 }
86};
87
88} // end namespace comma
89
90#endif // COMMA_PROJECT_PRIORITY_PAIR_H
Wrapper around the STL pair with custom 'less than' operator: as in the standard case,...
Definition: Priority_Pair.h:30
~Priority_Pair()=default
Destructor.
Priority_Pair(const A &a, const B &b)
Constructor.
Definition: Priority_Pair.h:44
friend bool operator==(const Priority_Pair &a, const Priority_Pair &b)
Operator 'equal'.
Definition: Priority_Pair.h:81
Priority_Pair()=default
Constructor.
friend bool operator<(const Priority_Pair &a, const Priority_Pair &b)
Operator 'less than'. It actually relies on the 'greater than' operator for the first elements and 'l...
Definition: Priority_Pair.h:69
B second() const
Accessor to the first element.
Definition: Priority_Pair.h:60
A first() const
Accessor to the first element.
Definition: Priority_Pair.h:55
Definition: Agglomerator.h:37