17 #ifndef VCSN_MISC_BITSET_HH
18 # define VCSN_MISC_BITSET_HH
30 # include <functional>
48 typedef int value_type;
49 typedef std::less<key_type> key_compare;
50 typedef key_compare value_compare;
54 typedef value_type reference;
55 typedef const value_type const_reference;
57 struct const_iterator;
58 typedef unsigned int size_type;
59 typedef int difference_type;
60 typedef value_type* pointer;
61 typedef const value_type* const_pointer;
62 typedef std::reverse_iterator<iterator> reverse_iterator;
63 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
66 typedef unsigned int data_type;
78 Bitset (size_type max,
const data_type* data);
84 template <
class InputIterator>
85 Bitset (InputIterator first, InputIterator last);
96 const_iterator
begin ()
const;
98 const_iterator
end ()
const;
103 reverse_iterator
rbegin ();
104 const_reverse_iterator
rbegin ()
const;
105 reverse_iterator
rend ();
106 const_reverse_iterator
rend ()
const;
110 size_type size ()
const;
111 size_type max_size ()
const;
115 std::pair<iterator, bool>
insert (
const value_type& x);
116 iterator
insert (iterator position,
const value_type& x);
117 template <
class InputIterator>
118 void insert (InputIterator first,
124 void erase (iterator position);
125 size_type
erase (
const key_type& x);
126 void erase (iterator first, iterator last);
135 key_compare key_comp ()
const;
136 value_compare value_comp ()
const;
139 iterator
find (
const key_type& x)
const;
142 size_type
count (
const key_type& x)
const;
144 iterator lower_bound (
const key_type& x)
const;
145 iterator upper_bound (
const key_type& x)
const;
146 std::pair<iterator, iterator> equal_range (
const key_type& x)
const;
148 bool operator== (
const Bitset& rhs)
const;
149 bool operator< (
const Bitset& rhs)
const;
177 template <
typename Type>
178 const Type
cast ()
const;
181 std::ostream&
print (std::ostream& ostr)
const;
197 bool get_bit (size_type index, size_type bit)
const;
207 bit_iterator (size_type index = 0, size_type bitnum = 0);
208 const bit_iterator& operator-- ();
209 const bit_iterator& operator++ ();
211 bool operator== (
const bit_iterator& rhs)
const;
212 bool operator!= (
const bit_iterator& rhs)
const;
221 bit_iterator bit_begin ()
const;
222 const bit_iterator& bit_end ()
const;
225 bool get_bit (
const bit_iterator& it)
const;
231 template <
typename CountType, CountType Start, CountType Step>
232 struct BitActionCount
236 bool operator() (
const Bitset& bitset,
248 template <
class BitAction>
249 bool do_on_bit (BitAction& action,
const key_type& x);
250 template <
class BitAction>
251 bool do_on_bit (BitAction& action,
const bit_iterator& it);
256 template <
class ConstBitAction>
257 bool do_on_bit (ConstBitAction& action,
const key_type& x)
const;
258 template <
class ConstBitAction>
260 const bit_iterator& it)
const;
267 enum { invalid_size = static_cast <
unsigned int> (-1) };
269 size_type data_size_;
273 mutable size_type size_;
282 struct const_iterator
284 typedef std::bidirectional_iterator_tag iterator_category;
285 typedef Bitset::value_type value_type;
286 typedef Bitset::difference_type difference_type;
287 typedef Bitset::reference reference;
288 typedef Bitset::pointer pointer;
291 const_iterator (
const Bitset* bs);
292 const_iterator (
const Bitset* bs,
const bit_iterator& cbit);
293 const_iterator (
const const_iterator& it);
294 const_iterator (
const iterator& it);
296 const const_iterator& operator++ ();
297 const_iterator operator++ (
int);
298 const const_iterator& operator-- ();
299 const_iterator operator-- (
int);
300 bool operator== (
const const_iterator& rhs)
const;
301 bool operator== (
const iterator& rhs)
const;
302 bool operator!= (
const const_iterator& rhs)
const;
303 bool operator!= (
const iterator& rhs)
const;
307 void skip_zeros_forward ();
308 void skip_zeros_backward ();
320 typedef std::bidirectional_iterator_tag iterator_category;
321 typedef Bitset::value_type value_type;
322 typedef Bitset::difference_type difference_type;
323 typedef Bitset::reference reference;
324 typedef Bitset::pointer pointer;
327 iterator (
const Bitset* bs);
328 iterator (
const Bitset* bs,
const bit_iterator& cbit);
329 iterator (
const iterator& it);
332 friend const_iterator::const_iterator (
const iterator& it);
334 const iterator& operator++ ();
335 iterator operator++ (
int);
336 const iterator& operator-- ();
337 iterator operator-- (
int);
338 bool operator== (
const iterator& rhs)
const;
339 bool operator== (
const const_iterator& rhs)
const;
340 bool operator!= (
const iterator& rhs)
const;
341 bool operator!= (
const const_iterator& rhs)
const;
345 void skip_zeros_forward ();
346 void skip_zeros_backward ();
369 class insert_iterator<vcsn::misc::Bitset> :
370 public iterator<output_iterator_tag, void, void, void, void>
377 operator= (vcsn::misc::Bitset::const_reference value);
387 # if !defined VCSN_USE_INTERFACE_ONLY || defined VCSN_USE_LIB
389 # endif // VCSN_USE_INTERFACE_ONLY
392 #endif // ! VCSN_MISC_BITSET_HH