// (C) Copyright 2008-2009 SDML (www.sdml.info) // // Use, modification and distribution is subject to the Boost Software // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt) // Copyright Andrew Sutton 2007 // // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) #include #include #include #include using namespace std; using namespace boost; using namespace boost::sets; template void test(Set& s, Set& t) { add(s, 1); add(s, 2); add(s, 3); add(t, 1); add(t, 4); add(t, 5); cout << "s: "; copy(begin(s), end(s), ostream_iterator(cout, " ")); cout << endl; cout << "t: "; copy(begin(t), end(t), ostream_iterator(cout, " ")); cout << endl; Set x = difference(s, t); cout << "difference(s,t) == "; copy(begin(x), end(x), ostream_iterator(cout, " ")); cout << endl; Set y = union_(s, t); cout << "union(s,t) == "; copy(begin(y), end(y), ostream_iterator(cout, " ")); cout << endl; cout << "subset(x, s) == " << is_subset(x, s) << endl; cout << "subset(s, x) == " << is_subset(s, x) << endl; cout << "subset(s, s) == " << is_subset(s, s) << endl; cout << "proper_subset(x, s) == " << is_proper_subset(x, s) << endl; cout << "proper_subset(s, s) == " << is_proper_subset(s, s) << endl; cout << "disjoint(t,x) == " << are_disjoint(t, x) << endl; } int main(int argc, char *argv[]) { { cout << "ordered set" << endl; set s, t; test(s, t); cout << endl; } { cout << "bitset" << endl; dynamic_bitset<> s(10), t(10); test(s, t); cout << endl; } return 0; }