4 * Hewlett-Packard Company
6 * Permission to use, copy, modify, distribute and sell this software
7 * and its documentation for any purpose is hereby granted without fee,
8 * provided that the above copyright notice appear in all copies and
9 * that both that copyright notice and this permission notice appear
10 * in supporting documentation. Hewlett-Packard Company makes no
11 * representations about the suitability of this software for any
12 * purpose. It is provided "as is" without express or implied warranty.
15 * Copyright (c) 1996,1997
16 * Silicon Graphics Computer Systems, Inc.
18 * Permission to use, copy, modify, distribute and sell this software
19 * and its documentation for any purpose is hereby granted without fee,
20 * provided that the above copyright notice appear in all copies and
21 * that both that copyright notice and this permission notice appear
22 * in supporting documentation. Silicon Graphics makes no
23 * representations about the suitability of this software for any
24 * purpose. It is provided "as is" without express or implied warranty.
27 /* NOTE: This is an internal header file, included by other STL headers.
28 * You should not attempt to use it directly.
31 #ifndef __SGI_STL_INTERNAL_BVECTOR_H
32 #define __SGI_STL_INTERNAL_BVECTOR_H
36 static const int __WORD_BIT = int(CHAR_BIT*sizeof(unsigned int));
38 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
43 struct _Bit_reference {
46 _Bit_reference(unsigned int* __x, unsigned int __y)
47 : _M_p(__x), _M_mask(__y) {}
50 _Bit_reference() : _M_p(0), _M_mask(0) {}
51 operator bool() const { return !(!(*_M_p & _M_mask)); }
52 _Bit_reference& operator=(bool __x)
54 if (__x) *_M_p |= _M_mask;
55 else *_M_p &= ~_M_mask;
58 _Bit_reference& operator=(const _Bit_reference& __x)
59 { return *this = bool(__x); }
60 bool operator==(const _Bit_reference& __x) const
61 { return bool(*this) == bool(__x); }
62 bool operator<(const _Bit_reference& __x) const {
63 return !bool(*this) && bool(__x);
65 void flip() { *_M_p ^= _M_mask; }
68 inline void swap(_Bit_reference __x, _Bit_reference __y)
75 struct _Bit_iterator : public random_access_iterator<bool, ptrdiff_t> {
76 typedef _Bit_reference reference;
77 typedef _Bit_reference* pointer;
78 typedef _Bit_iterator iterator;
81 unsigned int _M_offset;
83 if (_M_offset++ == __WORD_BIT - 1) {
89 if (_M_offset-- == 0) {
90 _M_offset = __WORD_BIT - 1;
95 _Bit_iterator() : _M_p(0), _M_offset(0) {}
96 _Bit_iterator(unsigned int* __x, unsigned int __y)
97 : _M_p(__x), _M_offset(__y) {}
98 reference operator*() const { return reference(_M_p, 1U << _M_offset); }
99 iterator& operator++() {
103 iterator operator++(int) {
104 iterator __tmp = *this;
108 iterator& operator--() {
112 iterator operator--(int) {
113 iterator __tmp = *this;
117 iterator& operator+=(difference_type __i) {
118 difference_type __n = __i + _M_offset;
119 _M_p += __n / __WORD_BIT;
120 __n = __n % __WORD_BIT;
122 _M_offset = (unsigned int) __n + __WORD_BIT;
125 _M_offset = (unsigned int) __n;
128 iterator& operator-=(difference_type __i) {
132 iterator operator+(difference_type __i) const {
133 iterator __tmp = *this;
136 iterator operator-(difference_type __i) const {
137 iterator __tmp = *this;
140 difference_type operator-(iterator __x) const {
141 return __WORD_BIT * (_M_p - __x._M_p) + _M_offset - __x._M_offset;
143 reference operator[](difference_type __i) { return *(*this + __i); }
144 bool operator==(const iterator& __x) const {
145 return _M_p == __x._M_p && _M_offset == __x._M_offset;
147 bool operator!=(const iterator& __x) const {
148 return _M_p != __x._M_p || _M_offset != __x._M_offset;
150 bool operator<(iterator __x) const {
151 return _M_p < __x._M_p || (_M_p == __x._M_p && _M_offset < __x._M_offset);
155 struct _Bit_const_iterator
156 : public random_access_iterator<bool, ptrdiff_t>
158 typedef bool reference;
159 typedef bool const_reference;
160 typedef const bool* pointer;
161 typedef _Bit_const_iterator const_iterator;
164 unsigned int _M_offset;
166 if (_M_offset++ == __WORD_BIT - 1) {
172 if (_M_offset-- == 0) {
173 _M_offset = __WORD_BIT - 1;
178 _Bit_const_iterator() : _M_p(0), _M_offset(0) {}
179 _Bit_const_iterator(unsigned int* __x, unsigned int __y)
180 : _M_p(__x), _M_offset(__y) {}
181 _Bit_const_iterator(const _Bit_iterator& __x)
182 : _M_p(__x._M_p), _M_offset(__x._M_offset) {}
183 const_reference operator*() const {
184 return _Bit_reference(_M_p, 1U << _M_offset);
186 const_iterator& operator++() {
190 const_iterator operator++(int) {
191 const_iterator __tmp = *this;
195 const_iterator& operator--() {
199 const_iterator operator--(int) {
200 const_iterator __tmp = *this;
204 const_iterator& operator+=(difference_type __i) {
205 difference_type __n = __i + _M_offset;
206 _M_p += __n / __WORD_BIT;
207 __n = __n % __WORD_BIT;
209 _M_offset = (unsigned int) __n + __WORD_BIT;
212 _M_offset = (unsigned int) __n;
215 const_iterator& operator-=(difference_type __i) {
219 const_iterator operator+(difference_type __i) const {
220 const_iterator __tmp = *this;
223 const_iterator operator-(difference_type __i) const {
224 const_iterator __tmp = *this;
227 difference_type operator-(const_iterator __x) const {
228 return __WORD_BIT * (_M_p - __x._M_p) + _M_offset - __x._M_offset;
230 const_reference operator[](difference_type __i) {
231 return *(*this + __i);
233 bool operator==(const const_iterator& __x) const {
234 return _M_p == __x._M_p && _M_offset == __x._M_offset;
236 bool operator!=(const const_iterator& __x) const {
237 return _M_p != __x._M_p || _M_offset != __x._M_offset;
239 bool operator<(const_iterator __x) const {
240 return _M_p < __x._M_p || (_M_p == __x._M_p && _M_offset < __x._M_offset);
244 // Bit-vector base class, which encapsulates the difference between
245 // old SGI-style allocators and standard-conforming allocators.
247 #ifdef __STL_USE_STD_ALLOCATORS
249 // Base class for ordinary allocators.
250 template <class _Allocator, bool __is_static>
251 class _Bvector_alloc_base {
253 typedef typename _Alloc_traits<bool, _Allocator>::allocator_type
255 allocator_type get_allocator() const { return _M_data_allocator; }
257 _Bvector_alloc_base(const allocator_type& __a)
258 : _M_data_allocator(__a), _M_start(), _M_finish(), _M_end_of_storage(0) {}
261 unsigned int* _M_bit_alloc(size_t __n)
262 { return _M_data_allocator.allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }
263 void _M_deallocate() {
265 _M_data_allocator.deallocate(_M_start._M_p,
266 _M_end_of_storage - _M_start._M_p);
269 typename _Alloc_traits<unsigned int, _Allocator>::allocator_type
271 _Bit_iterator _M_start;
272 _Bit_iterator _M_finish;
273 unsigned int* _M_end_of_storage;
276 // Specialization for instanceless allocators.
277 template <class _Allocator>
278 class _Bvector_alloc_base<_Allocator, true> {
280 typedef typename _Alloc_traits<bool, _Allocator>::allocator_type
282 allocator_type get_allocator() const { return allocator_type(); }
284 _Bvector_alloc_base(const allocator_type&)
285 : _M_start(), _M_finish(), _M_end_of_storage(0) {}
288 typedef typename _Alloc_traits<unsigned int, _Allocator>::_Alloc_type
291 unsigned int* _M_bit_alloc(size_t __n)
292 { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }
293 void _M_deallocate() {
295 _Alloc_type::deallocate(_M_start._M_p,
296 _M_end_of_storage - _M_start._M_p);
299 _Bit_iterator _M_start;
300 _Bit_iterator _M_finish;
301 unsigned int* _M_end_of_storage;
304 template <class _Alloc>
306 : public _Bvector_alloc_base<_Alloc,
307 _Alloc_traits<bool, _Alloc>::_S_instanceless>
309 typedef _Bvector_alloc_base<_Alloc,
310 _Alloc_traits<bool, _Alloc>::_S_instanceless>
313 typedef typename _Base::allocator_type allocator_type;
315 _Bvector_base(const allocator_type& __a) : _Base(__a) {}
316 ~_Bvector_base() { _Base::_M_deallocate(); }
319 #else /* __STL_USE_STD_ALLOCATORS */
321 template <class _Alloc>
325 typedef _Alloc allocator_type;
326 allocator_type get_allocator() const { return allocator_type(); }
328 _Bvector_base(const allocator_type&)
329 : _M_start(), _M_finish(), _M_end_of_storage(0) {}
330 ~_Bvector_base() { _M_deallocate(); }
333 typedef simple_alloc<unsigned int, _Alloc> _Alloc_type;
335 unsigned int* _M_bit_alloc(size_t __n)
336 { return _Alloc_type::allocate((__n + __WORD_BIT - 1)/__WORD_BIT); }
337 void _M_deallocate() {
339 _Alloc_type::deallocate(_M_start._M_p,
340 _M_end_of_storage - _M_start._M_p);
343 _Bit_iterator _M_start;
344 _Bit_iterator _M_finish;
345 unsigned int* _M_end_of_storage;
348 #endif /* __STL_USE_STD_ALLOCATORS */
350 // The next few lines are confusing. What we're doing is declaring a
351 // partial specialization of vector<T, Alloc> if we have the necessary
352 // compiler support. Otherwise, we define a class bit_vector which uses
353 // the default allocator.
355 #if defined(__STL_CLASS_PARTIAL_SPECIALIZATION) && !defined(__STL_NO_BOOL)
356 #define __SGI_STL_VECBOOL_TEMPLATE
357 #define __BVECTOR vector
359 #undef __SGI_STL_VECBOOL_TEMPLATE
360 #define __BVECTOR bit_vector
363 # ifdef __SGI_STL_VECBOOL_TEMPLATE
365 # include <stl_vector.h>
366 __STL_BEGIN_NAMESPACE
367 template<class _Alloc> class vector<bool,_Alloc>
368 : public _Bvector_base<_Alloc>
369 # else /* __SGI_STL_VECBOOL_TEMPLATE */
371 : public _Bvector_base<__STL_DEFAULT_ALLOCATOR(bool) >
372 # endif /* __SGI_STL_VECBOOL_TEMPLATE */
374 # ifdef __SGI_STL_VECBOOL_TEMPLATE
375 typedef _Bvector_base<_Alloc> _Base;
376 # else /* __SGI_STL_VECBOOL_TEMPLATE */
377 typedef _Bvector_base<__STL_DEFAULT_ALLOCATOR(bool) > _Base;
378 # endif /* __SGI_STL_VECBOOL_TEMPLATE */
380 typedef bool value_type;
381 typedef size_t size_type;
382 typedef ptrdiff_t difference_type;
383 typedef _Bit_reference reference;
384 typedef bool const_reference;
385 typedef _Bit_reference* pointer;
386 typedef const bool* const_pointer;
388 typedef _Bit_iterator iterator;
389 typedef _Bit_const_iterator const_iterator;
391 #ifdef __STL_CLASS_PARTIAL_SPECIALIZATION
392 typedef reverse_iterator<const_iterator> const_reverse_iterator;
393 typedef reverse_iterator<iterator> reverse_iterator;
394 #else /* __STL_CLASS_PARTIAL_SPECIALIZATION */
395 typedef reverse_iterator<const_iterator, value_type, const_reference,
396 difference_type> const_reverse_iterator;
397 typedef reverse_iterator<iterator, value_type, reference, difference_type>
399 #endif /* __STL_CLASS_PARTIAL_SPECIALIZATION */
401 typedef typename _Base::allocator_type allocator_type;
402 allocator_type get_allocator() const { return _Base::get_allocator(); }
405 #ifdef __STL_USE_NAMESPACES
406 using _Base::_M_bit_alloc;
407 using _Base::_M_deallocate;
408 using _Base::_M_start;
409 using _Base::_M_finish;
410 using _Base::_M_end_of_storage;
411 #endif /* __STL_USE_NAMESPACES */
414 void _M_initialize(size_type __n) {
415 unsigned int* __q = _M_bit_alloc(__n);
416 _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT;
417 _M_start = iterator(__q, 0);
418 _M_finish = _M_start + difference_type(__n);
420 void _M_insert_aux(iterator __position, bool __x) {
421 if (_M_finish._M_p != _M_end_of_storage) {
422 copy_backward(__position, _M_finish, _M_finish + 1);
427 size_type __len = size() ? 2 * size() : __WORD_BIT;
428 unsigned int* __q = _M_bit_alloc(__len);
429 iterator __i = copy(begin(), __position, iterator(__q, 0));
431 _M_finish = copy(__position, end(), __i);
433 _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
434 _M_start = iterator(__q, 0);
438 #ifdef __STL_MEMBER_TEMPLATES
439 template <class _InputIterator>
440 void _M_initialize_range(_InputIterator __first, _InputIterator __last,
441 input_iterator_tag) {
442 _M_start = iterator();
443 _M_finish = iterator();
444 _M_end_of_storage = 0;
445 for ( ; __first != __last; ++__first)
449 template <class _ForwardIterator>
450 void _M_initialize_range(_ForwardIterator __first, _ForwardIterator __last,
451 forward_iterator_tag) {
453 distance(__first, __last, __n);
455 copy(__first, __last, _M_start);
458 template <class _InputIterator>
459 void _M_insert_range(iterator __pos,
460 _InputIterator __first, _InputIterator __last,
461 input_iterator_tag) {
462 for ( ; __first != __last; ++__first) {
463 __pos = insert(__pos, *__first);
468 template <class _ForwardIterator>
469 void _M_insert_range(iterator __position,
470 _ForwardIterator __first, _ForwardIterator __last,
471 forward_iterator_tag) {
472 if (__first != __last) {
474 distance(__first, __last, __n);
475 if (capacity() - size() >= __n) {
476 copy_backward(__position, end(), _M_finish + difference_type(__n));
477 copy(__first, __last, __position);
478 _M_finish += difference_type(__n);
481 size_type __len = size() + max(size(), __n);
482 unsigned int* __q = _M_bit_alloc(__len);
483 iterator __i = copy(begin(), __position, iterator(__q, 0));
484 __i = copy(__first, __last, __i);
485 _M_finish = copy(__position, end(), __i);
487 _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
488 _M_start = iterator(__q, 0);
493 #endif /* __STL_MEMBER_TEMPLATES */
496 iterator begin() { return _M_start; }
497 const_iterator begin() const { return _M_start; }
498 iterator end() { return _M_finish; }
499 const_iterator end() const { return _M_finish; }
501 reverse_iterator rbegin() { return reverse_iterator(end()); }
502 const_reverse_iterator rbegin() const {
503 return const_reverse_iterator(end());
505 reverse_iterator rend() { return reverse_iterator(begin()); }
506 const_reverse_iterator rend() const {
507 return const_reverse_iterator(begin());
510 size_type size() const { return size_type(end() - begin()); }
511 size_type max_size() const { return size_type(-1); }
512 size_type capacity() const {
513 return size_type(const_iterator(_M_end_of_storage, 0) - begin());
515 bool empty() const { return begin() == end(); }
516 reference operator[](size_type __n) {
517 return *(begin() + difference_type(__n));
519 const_reference operator[](size_type __n) const {
520 return *(begin() + difference_type(__n));
523 explicit __BVECTOR(const allocator_type& __a = allocator_type())
526 __BVECTOR(size_type __n, bool __value,
527 const allocator_type& __a = allocator_type())
531 fill(_M_start._M_p, _M_end_of_storage, __value ? ~0 : 0);
534 explicit __BVECTOR(size_type __n)
535 : _Base(allocator_type())
538 fill(_M_start._M_p, _M_end_of_storage, 0);
541 __BVECTOR(const __BVECTOR& __x) : _Base(__x.get_allocator()) {
542 _M_initialize(__x.size());
543 copy(__x.begin(), __x.end(), _M_start);
546 #ifdef __STL_MEMBER_TEMPLATES
547 // Check whether it's an integral type. If so, it's not an iterator.
548 template <class _InputIterator>
549 __BVECTOR(_InputIterator __first, _InputIterator __last,
550 const allocator_type& __a = allocator_type())
553 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
554 _M_initialize_dispatch(__first, __last, _Integral());
557 template <class _Integer>
558 void _M_initialize_dispatch(_Integer __n, _Integer __x, __true_type) {
560 fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);
563 template <class _InputIterator>
564 void _M_initialize_dispatch(_InputIterator __first, _InputIterator __last,
566 _M_initialize_range(__first, __last, __ITERATOR_CATEGORY(__first));
568 #else /* __STL_MEMBER_TEMPLATES */
569 __BVECTOR(const_iterator __first, const_iterator __last,
570 const allocator_type& __a = allocator_type())
574 distance(__first, __last, __n);
576 copy(__first, __last, _M_start);
578 __BVECTOR(const bool* __first, const bool* __last,
579 const allocator_type& __a = allocator_type())
583 distance(__first, __last, __n);
585 copy(__first, __last, _M_start);
587 #endif /* __STL_MEMBER_TEMPLATES */
591 __BVECTOR& operator=(const __BVECTOR& __x) {
592 if (&__x == this) return *this;
593 if (__x.size() > capacity()) {
595 _M_initialize(__x.size());
597 copy(__x.begin(), __x.end(), begin());
598 _M_finish = begin() + difference_type(__x.size());
602 // assign(), a generalized assignment member function. Two
603 // versions: one that takes a count, and one that takes a range.
604 // The range version is a member template, so we dispatch on whether
605 // or not the type is an integer.
607 void assign(size_t __n, bool __x) {
609 fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);
610 insert(end(), __n - size(), __x);
613 erase(begin() + __n, end());
614 fill(_M_start._M_p, _M_end_of_storage, __x ? ~0 : 0);
618 #ifdef __STL_MEMBER_TEMPLATES
620 template <class _InputIterator>
621 void assign(_InputIterator __first, _InputIterator __last) {
622 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
623 _M_assign_dispatch(__first, __last, _Integral());
626 template <class _Integer>
627 void _M_assign_dispatch(_Integer __n, _Integer __val, __true_type)
628 { assign((size_t) __n, (bool) __val); }
630 template <class _InputIter>
631 void _M_assign_dispatch(_InputIter __first, _InputIter __last, __false_type)
632 { _M_assign_aux(__first, __last, __ITERATOR_CATEGORY(__first)); }
634 template <class _InputIterator>
635 void _M_assign_aux(_InputIterator __first, _InputIterator __last,
636 input_iterator_tag) {
637 iterator __cur = begin();
638 for ( ; __first != __last && __cur != end(); ++__cur, ++__first)
640 if (__first == __last)
643 insert(end(), __first, __last);
646 template <class _ForwardIterator>
647 void _M_assign_aux(_ForwardIterator __first, _ForwardIterator __last,
648 forward_iterator_tag) {
650 distance(__first, __last, __len);
652 erase(copy(__first, __last, begin()), end());
654 _ForwardIterator __mid = __first;
655 advance(__mid, size());
656 copy(__first, __mid, begin());
657 insert(end(), __mid, __last);
661 #endif /* __STL_MEMBER_TEMPLATES */
663 void reserve(size_type __n) {
664 if (capacity() < __n) {
665 unsigned int* __q = _M_bit_alloc(__n);
666 _M_finish = copy(begin(), end(), iterator(__q, 0));
668 _M_start = iterator(__q, 0);
669 _M_end_of_storage = __q + (__n + __WORD_BIT - 1)/__WORD_BIT;
673 reference front() { return *begin(); }
674 const_reference front() const { return *begin(); }
675 reference back() { return *(end() - 1); }
676 const_reference back() const { return *(end() - 1); }
677 void push_back(bool __x) {
678 if (_M_finish._M_p != _M_end_of_storage)
681 _M_insert_aux(end(), __x);
683 void swap(__BVECTOR& __x) {
684 __STD::swap(_M_start, __x._M_start);
685 __STD::swap(_M_finish, __x._M_finish);
686 __STD::swap(_M_end_of_storage, __x._M_end_of_storage);
688 iterator insert(iterator __position, bool __x = bool()) {
689 difference_type __n = __position - begin();
690 if (_M_finish._M_p != _M_end_of_storage && __position == end())
693 _M_insert_aux(__position, __x);
694 return begin() + __n;
697 #ifdef __STL_MEMBER_TEMPLATES
698 // Check whether it's an integral type. If so, it's not an iterator.
699 template <class _InputIterator>
700 void insert(iterator __position,
701 _InputIterator __first, _InputIterator __last) {
702 typedef typename _Is_integer<_InputIterator>::_Integral _Integral;
703 _M_insert_dispatch(__position, __first, __last, _Integral());
706 template <class _Integer>
707 void _M_insert_dispatch(iterator __pos, _Integer __n, _Integer __x,
709 insert(__pos, (size_type) __n, (bool) __x);
712 template <class _InputIterator>
713 void _M_insert_dispatch(iterator __pos,
714 _InputIterator __first, _InputIterator __last,
716 _M_insert_range(__pos, __first, __last, __ITERATOR_CATEGORY(__first));
718 #else /* __STL_MEMBER_TEMPLATES */
719 void insert(iterator __position,
720 const_iterator __first, const_iterator __last) {
721 if (__first == __last) return;
723 distance(__first, __last, __n);
724 if (capacity() - size() >= __n) {
725 copy_backward(__position, end(), _M_finish + __n);
726 copy(__first, __last, __position);
730 size_type __len = size() + max(size(), __n);
731 unsigned int* __q = _M_bit_alloc(__len);
732 iterator __i = copy(begin(), __position, iterator(__q, 0));
733 __i = copy(__first, __last, __i);
734 _M_finish = copy(__position, end(), __i);
736 _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
737 _M_start = iterator(__q, 0);
741 void insert(iterator __position, const bool* __first, const bool* __last) {
742 if (__first == __last) return;
744 distance(__first, __last, __n);
745 if (capacity() - size() >= __n) {
746 copy_backward(__position, end(), _M_finish + __n);
747 copy(__first, __last, __position);
751 size_type __len = size() + max(size(), __n);
752 unsigned int* __q = _M_bit_alloc(__len);
753 iterator __i = copy(begin(), __position, iterator(__q, 0));
754 __i = copy(__first, __last, __i);
755 _M_finish = copy(__position, end(), __i);
757 _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
758 _M_start = iterator(__q, 0);
761 #endif /* __STL_MEMBER_TEMPLATES */
763 void insert(iterator __position, size_type __n, bool __x) {
764 if (__n == 0) return;
765 if (capacity() - size() >= __n) {
766 copy_backward(__position, end(), _M_finish + difference_type(__n));
767 fill(__position, __position + difference_type(__n), __x);
768 _M_finish += difference_type(__n);
771 size_type __len = size() + max(size(), __n);
772 unsigned int* __q = _M_bit_alloc(__len);
773 iterator __i = copy(begin(), __position, iterator(__q, 0));
774 fill_n(__i, __n, __x);
775 _M_finish = copy(__position, end(), __i + difference_type(__n));
777 _M_end_of_storage = __q + (__len + __WORD_BIT - 1)/__WORD_BIT;
778 _M_start = iterator(__q, 0);
782 void pop_back() { --_M_finish; }
783 iterator erase(iterator __position) {
784 if (__position + 1 != end())
785 copy(__position + 1, end(), __position);
789 iterator erase(iterator __first, iterator __last) {
790 _M_finish = copy(__last, end(), __first);
793 void resize(size_type __new_size, bool __x = bool()) {
794 if (__new_size < size())
795 erase(begin() + difference_type(__new_size), end());
797 insert(end(), __new_size - size(), __x);
799 void clear() { erase(begin(), end()); }
802 #ifdef __SGI_STL_VECBOOL_TEMPLATE
804 typedef vector<bool, alloc> bit_vector;
806 #else /* __SGI_STL_VECBOOL_TEMPLATE */
809 operator==(const bit_vector& __x, const bit_vector& __y)
811 return (__x.size() == __y.size() &&
812 equal(__x.begin(), __x.end(), __y.begin()));
816 operator<(const bit_vector& __x, const bit_vector& __y)
818 return lexicographical_compare(__x.begin(), __x.end(),
819 __y.begin(), __y.end());
822 #endif /* __SGI_STL_VECBOOL_TEMPLATE */
824 #undef __SGI_STL_VECBOOL_TEMPLATE
827 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
828 #pragma reset woff 1174
829 #pragma reset woff 1375
834 #endif /* __SGI_STL_INTERNAL_BVECTOR_H */