Vcsn  2.0
Be Rational
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
set.hh
Go to the documentation of this file.
1 #ifndef VCSN_MISC_SET_HH
2 # define VCSN_MISC_SET_HH
3 
4 # include <algorithm> // set_intersection
5 # include <map>
6 # include <set>
7 
8 # include <vcsn/misc/attributes.hh>
9 # include <vcsn/misc/hash.hh>
10 
11 namespace std
12 {
13 
14  /*---------------.
15  | hash(set<T>). |
16  `---------------*/
17 
18  template <typename T, typename Compare, typename Alloc>
19  struct hash<set<T, Compare, Alloc>>
20  {
21  using type = set<T, Compare, Alloc>;
22  size_t operator()(const type& ss) const
23  {
24  size_t res = 0;
25  for (const auto& s: ss)
26  hash_combine(res, s);
27  return res;
28  }
29  };
30 }
31 
32 namespace vcsn
33 {
35  template <typename T, typename Compare, typename Alloc>
36  bool
37  has(const std::set<T, Compare, Alloc>& s, const T& e)
38  ATTRIBUTE_PURE;
39 
41  template <typename Key, typename Value, typename Comp, typename Alloc>
42  std::set<typename std::map<Key, Value, Comp, Alloc>::mapped_type>
43  image(const std::map<Key, Value, Comp, Alloc>& m);
44 
46  template <typename T, typename Compare, typename Alloc>
47  std::set<T, Compare, Alloc>
48  intersection(const std::set<T, Compare, Alloc>& set1,
49  const std::set<T, Compare, Alloc>& set2);
50 
52  template <typename T, typename Compare, typename Alloc>
53  std::set<std::set<T, Compare, Alloc>>
54  intersection_closure(std::set<std::set<T, Compare, Alloc>> pset);
55 
57  template <typename T, typename Compare, typename Alloc>
58  std::set<T, Compare, Alloc>
59  get_union(const std::set<T, Compare, Alloc>& set1,
60  const std::set<T, Compare, Alloc>& set2);
61 
63  template <typename T, typename Compare, typename Alloc>
64  std::ostream&
65  print(const std::set<T, Compare, Alloc>& set, std::ostream& o);
66 
68  template <typename Container1, typename Container2>
69  bool subset(const Container1& set1, const Container2& set2)
70  ATTRIBUTE_PURE;
71 }
72 
73 # include <vcsn/misc/set.hxx>
74 
75 #endif // !VCSN_MISC_SET_HH
bool subset(const Container1 &set1, const Container2 &set2) ATTRIBUTE_PURE
Whether set1 ⊆ set2.
Definition: set.hxx:88
std::set< T, Compare, Alloc > get_union(const std::set< T, Compare, Alloc > &set1, const std::set< T, Compare, Alloc > &set2)
The union of two sets.
std::set< std::set< T, Compare, Alloc > > intersection_closure(std::set< std::set< T, Compare, Alloc >> pset)
The set of all the intersections of the sets in pset.
std::ostream & print(const ValueSet &vs, const typename ValueSet::value_t &v, std::ostream &o, const std::string &format)
Applies to (ValueSet, Value, ostream, string): for expansionset, polynomialset, ratexpset, and weightset.
Definition: print.hh:51
std::set< typename std::map< Key, Value, Comp, Alloc >::mapped_type > image(const std::map< Key, Value, Comp, Alloc > &m)
The set of values of a map.
Definition: set.hxx:16
std::set< T, Compare, Alloc > intersection(const std::set< T, Compare, Alloc > &set1, const std::set< T, Compare, Alloc > &set2)
The intersection of two sets.
size_t operator()(const type &ss) const
Definition: set.hh:22
set< T, Compare, Alloc > type
Definition: set.hh:21
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
Definition: map.hh:35