LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
set.hh
Go to the documentation of this file.
1 
12 #ifndef MISC_SET_HH
13 # define MISC_SET_HH
14 
15 # include <iosfwd>
16 # include <set>
17 # include <list>
18 # include <algorithm>
19 
20 namespace misc
21 {
22 
23  template <typename K,
24  typename C = std::less<K>,
25  typename A = std::allocator<K>>
32  class set : public std::set<K, C, A>
33  {
34  public:
35 
38  typedef typename std::set<K, C, A> set_type;
39 
40  typedef typename set_type::iterator iterator;
41  typedef typename set_type::const_iterator const_iterator;
42  typedef typename set_type::reverse_iterator reverse_iterator;
43  typedef typename set_type::const_reverse_iterator const_reverse_iterator;
44  typedef typename set_type::size_type size_type;
45  typedef typename set_type::const_reference const_reference;
47 
50 
51  explicit set();
52  template <typename Iter>
53  explicit set(Iter first, Iter last);
54 
55  /* Useful to convert a std::list in set::set. */
56  explicit set(const std::list<K> l);
57  ~set();
58 
60 
61 
65 
66  bool has(const K& k) const;
67 
70  set operator+(const K& data) const;
71 
74  set& operator+=(const K& data);
75 
78  set operator-(const K& data) const;
79 
82  set& operator-=(const K& data);
83 
85 
86 
90 
91  // FIXME: Deprecate this use, it ought to be direct sum.
92  set operator+(const set& s) const;
93 
95  set& operator+=(const set& s);
96 
98  set operator-(const set& s) const;
99 
101  set& operator-=(const set& s);
102 
104  set operator|(const set& s) const;
105 
107  set& operator|=(const set& s);
108 
110  set operator&(const set& s) const;
111 
113  set& operator&=(const set& s);
114 
116  }; // class set
117 
118  template <typename K, typename C, typename A>
119  inline set<K, C, A>
120  set_difference(const set<K, C, A>& s1,
121  const set<K, C, A>& s2);
122 
123  template <typename K, typename C, typename A>
124  inline set<K, C, A>
125  set_intersection(const set<K, C, A>& s1,
126  const set<K, C, A>& s2);
127 
128  template <typename K, typename C, typename A>
129  inline set<K, C, A>
130  set_union(const set<K, C, A>& s1,
131  const set<K, C, A>& s2);
132 
133 
134  /* Print a human-dump for debugging.
135 
136  Warning: this method requires that type Key overloads the operator
137  '<<'. If it is not the case do it or remove set print method
138  and << operator (see below). */
139  template <typename K, typename C, typename A>
140  inline std::ostream&
141  operator<<(std::ostream& ostr, const set<K, C, A>& s);
142 
143  template <typename K, typename C, typename A>
144  inline bool operator%(const K& k, const set<K, C, A>& s);
145 
146 } // namespace misc
147 
148 # include <misc/set.hxx>
149 
150 #endif // !MISC_SET_HH