@@ -132,23 +132,25 @@ class unsigned_union_find
132
132
size_type get_other (size_type a);
133
133
};
134
134
135
- template <typename T>
135
+ // / \tparam T: The type of values stored.
136
+ // / \tparam hasht: The type of hash used for looking up the value numbering.
137
+ template <typename T, typename hasht = std::hash<T>>
136
138
// NOLINTNEXTLINE(readability/identifiers)
137
139
class union_find final
138
140
{
139
- typedef numbering<T> numbering_typet ;
141
+ using numbering_typet = numberingt<T, hasht> ;
140
142
numbering_typet numbers;
141
143
142
144
// NOLINTNEXTLINE(readability/identifiers)
143
- typedef typename numbering_typet::number_type number_type;
145
+ using number_type = typename numbering_typet::number_type;
144
146
145
147
public:
146
148
// NOLINTNEXTLINE(readability/identifiers)
147
- typedef typename numbering_typet::size_type size_type;
149
+ using size_type = typename numbering_typet::size_type;
148
150
// NOLINTNEXTLINE(readability/identifiers)
149
- typedef typename numbering_typet::iterator iterator;
151
+ using iterator = typename numbering_typet::iterator;
150
152
// NOLINTNEXTLINE(readability/identifiers)
151
- typedef typename numbering_typet::const_iterator const_iterator;
153
+ using const_iterator = typename numbering_typet::const_iterator;
152
154
153
155
// true == already in same set
154
156
bool make_union (const T &a, const T &b)
@@ -160,8 +162,7 @@ class union_find final
160
162
}
161
163
162
164
// true == already in same set
163
- bool make_union (typename numbering<T>::const_iterator it_a,
164
- typename numbering<T>::const_iterator it_b)
165
+ bool make_union (const_iterator it_a, const_iterator it_b)
165
166
{
166
167
size_type na=it_a-numbers.begin (), nb=it_b-numbers.begin ();
167
168
bool is_union=find_number (na)==find_number (nb);
@@ -183,13 +184,12 @@ class union_find final
183
184
}
184
185
185
186
// are 'a' and 'b' in the same set?
186
- bool same_set (typename numbering<T>::const_iterator it_a,
187
- typename numbering<T>::const_iterator it_b) const
187
+ bool same_set (const_iterator it_a, const_iterator it_b) const
188
188
{
189
189
return uuf.same_set (it_a-numbers.begin (), it_b-numbers.begin ());
190
190
}
191
191
192
- const T &find (typename numbering<T>:: const_iterator it) const
192
+ const T &find (const_iterator it) const
193
193
{
194
194
return numbers[find_number (it-numbers.begin ())];
195
195
}
@@ -199,7 +199,7 @@ class union_find final
199
199
return numbers[find_number (number (a))];
200
200
}
201
201
202
- size_type find_number (typename numbering<T>:: const_iterator it) const
202
+ size_type find_number (const_iterator it) const
203
203
{
204
204
return find_number (it-numbers.begin ());
205
205
}
@@ -228,7 +228,7 @@ class union_find final
228
228
return uuf.is_root (na);
229
229
}
230
230
231
- bool is_root (typename numbering<T>:: const_iterator it) const
231
+ bool is_root (const_iterator it) const
232
232
{
233
233
return uuf.is_root (it-numbers.begin ());
234
234
}
@@ -251,7 +251,7 @@ class union_find final
251
251
uuf.clear ();
252
252
}
253
253
254
- void isolate (typename numbering<T>:: const_iterator it)
254
+ void isolate (const_iterator it)
255
255
{
256
256
uuf.isolate (it-numbers.begin ());
257
257
}
@@ -281,7 +281,7 @@ class union_find final
281
281
282
282
protected:
283
283
unsigned_union_find uuf;
284
- typedef numbering<T> subt;
284
+ using subt = numbering_typet ;
285
285
};
286
286
287
287
#endif // CPROVER_UTIL_UNION_FIND_H
0 commit comments