source: NonGTP/Boost/boost/graph/detail/bitset_adaptor.hpp @ 857

Revision 857, 2.8 KB checked in by igarcia, 19 years ago (diff)
Line 
1//=======================================================================
2// Copyright 2002 Indiana University.
3// Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
4//
5// Distributed under the Boost Software License, Version 1.0. (See
6// accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//=======================================================================
9
10#ifndef BOOST_BITSET_ADAPTOR_HPP
11#define BOOST_BITSET_ADAPTOR_HPP
12
13    template <class T, class Derived>
14    struct bitset_adaptor {
15      Derived& derived() { return static_cast<Derived&>(*this); }
16      const Derived& derived() const {
17        return static_cast<const Derived&>(*this);
18      }
19    };
20
21    template <class T, class D, class V>
22    bool set_contains(const bitset_adaptor<T,D>& s, const V& x) {
23      return s.derived().test(x);
24    }
25   
26    template <class T, class D>
27    bool set_equal(const bitset_adaptor<T,D>& x,
28                   const bitset_adaptor<T,D>& y) {
29      return x.derived() == y.derived();
30    }
31
32    template <class T, class D>
33    int set_lex_order(const bitset_adaptor<T,D>& x,
34                      const bitset_adaptor<T,D>& y) {
35      return compare_3way(x.derived(), y.derived());
36    }
37
38    template <class T, class D>
39    void set_clear(bitset_adaptor<T,D>& x) {
40      x.derived().reset();
41    }
42
43    template <class T, class D>
44    bool set_empty(const bitset_adaptor<T,D>& x) {
45      return x.derived().none();
46    }
47
48    template <class T, class D, class V>
49    void set_insert(bitset_adaptor<T,D>& x, const V& a) {
50      x.derived().set(a);
51    }
52
53    template <class T, class D, class V>
54    void set_remove(bitset_adaptor<T,D>& x, const V& a) {
55      x.derived().set(a, false);
56    }
57   
58    template <class T, class D>   
59    void set_intersect(const bitset_adaptor<T,D>& x,
60                       const bitset_adaptor<T,D>& y,
61                       bitset_adaptor<T,D>& z)
62    {
63      z.derived() = x.derived() & y.derived();
64    }
65
66    template <class T, class D>   
67    void set_union(const bitset_adaptor<T,D>& x,
68                   const bitset_adaptor<T,D>& y,
69                   bitset_adaptor<T,D>& z)
70    {
71      z.derived() = x.derived() | y.derived();
72    }
73
74    template <class T, class D>   
75    void set_difference(const bitset_adaptor<T,D>& x,
76                        const bitset_adaptor<T,D>& y,
77                        bitset_adaptor<T,D>& z)
78    {
79      z.derived() = x.derived() - y.derived();
80    }
81
82    template <class T, class D>   
83    void set_compliment(const bitset_adaptor<T,D>& x,
84                        bitset_adaptor<T,D>& z)
85    {
86      z.derived() = x.derived();
87      z.derived().flip();
88    }
89   
90#endif // BOOST_BITSET_ADAPTOR_HPP
Note: See TracBrowser for help on using the repository browser.