1
#ifndef TAGCOLL_UTILS_SET_H
2
#define TAGCOLL_UTILS_SET_H
5
* Extra useful set operations
9
* Copyright (C) 2003,2004,2005,2006 Enrico Zini <enrico@debian.org>
11
* This library is free software; you can redistribute it and/or
12
* modify it under the terms of the GNU Lesser General Public
13
* License as published by the Free Software Foundation; either
14
* version 2.1 of the License, or (at your option) any later version.
16
* This library is distributed in the hope that it will be useful,
17
* but WITHOUT ANY WARRANTY; without even the implied warranty of
18
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19
* Lesser General Public License for more details.
21
* You should have received a copy of the GNU Lesser General Public
22
* License along with this library; if not, write to the Free Software
23
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26
#include <wibble/operators.h>
33
int set_distance(const std::set<T>& set1, const std::set<T>& set2)
38
typename std::set<T>::const_iterator a = set1.begin();
39
typename std::set<T>::const_iterator b = set2.begin();
41
while (a != set1.end() || b != set2.end())
42
if ((b == set2.end()) || (a != set1.end() && *a < *b))
47
else if ((a == set1.end()) || (b != set2.end() && *b < *a))
59
return intCount ? res : -1;
63
bool set_contains(const std::set<T>& set1, const std::set<T>& set2)
65
typename std::set<T>::const_iterator b = set2.begin();
67
for (typename std::set<T>::const_iterator a = set1.begin(); a != set1.end(); ++a)
75
return b == set2.end();
79
bool set_contains(const std::set<T>& set1, const T& item)
81
return set1.find(item) != set1.end();