Awali
Another Weighted Automata library
pair.hh
Go to the documentation of this file.
1 // This file is part of Awali.
2 // Copyright 2016-2022 Sylvain Lombardy, Victor Marsault, Jacques Sakarovitch
3 //
4 // Awali is a free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef AWALI_MISC_PAIR_HH
18 # define AWALI_MISC_PAIR_HH
19 
21 #include <awali/utils/hash.hh>
22 
23 namespace std
24 {
25 
26  /*---------------.
27  | hash(pair<T>). |
28  `---------------*/
29 
30  template <typename T1, typename T2>
31  struct hash<pair<T1, T2>>
32  {
33  size_t operator()(const pair<T1, T2>& p) const
34  {
35  size_t res = 0;
36  hash_combine(res, p.first);
37  hash_combine(res, p.second);
38  return res;
39  }
40  };
41 }
42 
43 
44 namespace awali { namespace sttc {
45 
46 
47  /*---------------------------------.
48  | make_ordered_pair(e1<T>, e2<T>). |
49  `---------------------------------*/
50 
51  template <typename T>
52  std::pair<T, T> make_ordered_pair(T e1, T e2)
53  {
54  return e1 < e2 ? std::make_pair(e1, e2) : std::make_pair(e2, e1);
55  }
56 }}//end of ns awali::stc
57 
58 #endif // !AWALI_MISC_PAIR_HH
std::pair< T, T > make_ordered_pair(T e1, T e2)
Definition: pair.hh:52
pair_automaton< Aut > pair(const Aut &aut, bool keep_initials=false)
Definition: synchronizing_word.hh:266
Main namespace of Awali.
Definition: ato.hh:22
size_t operator()(const pair< T1, T2 > &p) const
Definition: pair.hh:33
void hash_combine(std::size_t &seed, const T &v)
Definition: hash.hh:27