home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / vector < prev    next >
Text File  |  1998-06-16  |  19KB  |  623 lines

  1. // vector standard header
  2.  
  3. #if     _MSC_VER > 1000
  4. #pragma once
  5. #endif
  6.  
  7. #ifndef _VECTOR_
  8. #define _VECTOR_
  9. #include <climits>
  10. #include <memory>
  11. #include <stdexcept>
  12. #include <xutility>
  13.  
  14. #ifdef  _MSC_VER
  15. #pragma pack(push,8)
  16. #endif  /* _MSC_VER */
  17. _STD_BEGIN
  18.         // TEMPLATE CLASS vector
  19. template<class _Ty, class _A = allocator<_Ty> >
  20.     class vector {
  21. public:
  22.     typedef vector<_Ty, _A> _Myt;
  23.     typedef _A allocator_type;
  24.     typedef _A::size_type size_type;
  25.     typedef _A::difference_type difference_type;
  26.     typedef _A::pointer _Tptr;
  27.     typedef _A::const_pointer _Ctptr;
  28.     typedef _A::reference reference;
  29.     typedef _A::const_reference const_reference;
  30.     typedef _A::value_type value_type;
  31.     typedef _Tptr iterator;
  32.     typedef _Ctptr const_iterator;
  33.     typedef reverse_iterator<const_iterator, value_type,
  34.         const_reference, _Ctptr, difference_type>
  35.             const_reverse_iterator;
  36.     typedef reverse_iterator<iterator, value_type,
  37.         reference, _Tptr, difference_type>
  38.             reverse_iterator;
  39.     explicit vector(const _A& _Al = _A())
  40.         : allocator(_Al), _First(0), _Last(0), _End(0) {}
  41.     explicit vector(size_type _N, const _Ty& _V = _Ty(),
  42.         const _A& _Al = _A())
  43.         : allocator(_Al)
  44.         {_First = allocator.allocate(_N, (void *)0);
  45.         _Ufill(_First, _N, _V);
  46.         _Last = _First + _N;
  47.         _End = _Last; }
  48.     vector(const _Myt& _X)
  49.         : allocator(_X.allocator)
  50.         {_First = allocator.allocate(_X.size(), (void *)0);
  51.         _Last = _Ucopy(_X.begin(), _X.end(), _First);
  52.         _End = _Last; }
  53.     typedef const_iterator _It;
  54.     vector(_It _F, _It _L, const _A& _Al = _A())
  55.         : allocator(_Al), _First(0), _Last(0), _End(0)
  56.         {insert(begin(), _F, _L); }
  57.     ~vector()
  58.         {_Destroy(_First, _Last);
  59.         allocator.deallocate(_First, _End - _First);
  60.         _First = 0, _Last = 0, _End = 0; }
  61.     _Myt& operator=(const _Myt& _X)
  62.         {if (this == &_X)
  63.             ;
  64.         else if (_X.size() <= size())
  65.             {iterator _S = copy(_X.begin(), _X.end(), _First);
  66.             _Destroy(_S, _Last);
  67.             _Last = _First + _X.size(); }
  68.         else if (_X.size() <= capacity())
  69.             {const_iterator _S = _X.begin() + size();
  70.             copy(_X.begin(), _S, _First);
  71.             _Ucopy(_S, _X.end(), _Last);
  72.             _Last = _First + _X.size(); }
  73.         else
  74.             {_Destroy(_First, _Last);
  75.             allocator.deallocate(_First, _End - _First);
  76.             _First = allocator.allocate(_X.size(), (void *)0);
  77.             _Last = _Ucopy(_X.begin(), _X.end(),
  78.                 _First);
  79.             _End = _Last; }
  80.         return (*this); }
  81.     void reserve(size_type _N)
  82.         {if (capacity() < _N)
  83.             {iterator _S = allocator.allocate(_N, (void *)0);
  84.             _Ucopy(_First, _Last, _S);
  85.             _Destroy(_First, _Last);
  86.             allocator.deallocate(_First, _End - _First);
  87.             _End = _S + _N;
  88.             _Last = _S + size();
  89.             _First = _S; }}
  90.     size_type capacity() const
  91.         {return (_First == 0 ? 0 : _End - _First); }
  92.     iterator begin()
  93.         {return (_First); }
  94.     const_iterator begin() const
  95.         {return ((const_iterator)_First); }
  96.     iterator end()
  97.         {return (_Last); }
  98.     const_iterator end() const
  99.         {return ((const_iterator)_Last); }
  100.     reverse_iterator rbegin()
  101.         {return (reverse_iterator(end())); }
  102.     const_reverse_iterator rbegin() const
  103.         {return (const_reverse_iterator(end())); }
  104.     reverse_iterator rend()
  105.         {return (reverse_iterator(begin())); }
  106.     const_reverse_iterator rend() const
  107.         {return (const_reverse_iterator(begin())); }
  108.     void resize(size_type _N, const _Ty& _X = _Ty())
  109.         {if (size() < _N)
  110.             insert(end(), _N - size(), _X);
  111.         else if (_N < size())
  112.             erase(begin() + _N, end()); }
  113.     size_type size() const
  114.         {return (_First == 0 ? 0 : _Last - _First); }
  115.     size_type max_size() const
  116.         {return (allocator.max_size()); }
  117.     bool empty() const
  118.         {return (size() == 0); }
  119.     _A get_allocator() const
  120.         {return (allocator); }
  121.     const_reference at(size_type _P) const
  122.         {if (size() <= _P)
  123.             _Xran();
  124.         return (*(begin() + _P)); }
  125.     reference at(size_type _P)
  126.         {if (size() <= _P)
  127.             _Xran();
  128.         return (*(begin() + _P)); }
  129.     const_reference operator[](size_type _P) const
  130.         {return (*(begin() + _P)); }
  131.     reference operator[](size_type _P)
  132.         {return (*(begin() + _P)); }
  133.     reference front()
  134.         {return (*begin()); }
  135.     const_reference front() const
  136.         {return (*begin()); }
  137.     reference back()
  138.         {return (*(end() - 1)); }
  139.     const_reference back() const
  140.         {return (*(end() - 1)); }
  141.     void push_back(const _Ty& _X)
  142.         {insert(end(), _X); }
  143.     void pop_back()
  144.         {erase(end() - 1); }
  145.     void assign(_It _F, _It _L)
  146.         {erase(begin(), end());
  147.         insert(begin(), _F, _L); }
  148.     void assign(size_type _N, const _Ty& _X = _Ty())
  149.         {erase(begin(), end());
  150.         insert(begin(), _N, _X); }
  151.     iterator insert(iterator _P, const _Ty& _X = _Ty())
  152.         {size_type _O = _P - begin();
  153.         insert(_P, 1, _X);
  154.         return (begin() + _O); }
  155.     void insert(iterator _P, size_type _M, const _Ty& _X)
  156.         {if (_End - _Last < _M)
  157.             {size_type _N = size() + (_M < size() ? size() : _M);
  158.             iterator _S = allocator.allocate(_N, (void *)0);
  159.             iterator _Q = _Ucopy(_First, _P, _S);
  160.             _Ufill(_Q, _M, _X);
  161.             _Ucopy(_P, _Last, _Q + _M);
  162.             _Destroy(_First, _Last);
  163.             allocator.deallocate(_First, _End - _First);
  164.             _End = _S + _N;
  165.             _Last = _S + size() + _M;
  166.             _First = _S; }
  167.         else if (_Last - _P < _M)
  168.             {_Ucopy(_P, _Last, _P + _M);
  169.             _Ufill(_Last, _M - (_Last - _P), _X);
  170.             fill(_P, _Last, _X);
  171.             _Last += _M; }
  172.         else if (0 < _M)
  173.             {_Ucopy(_Last - _M, _Last, _Last);
  174.             copy_backward(_P, _Last - _M, _Last);
  175.             fill(_P, _P + _M, _X);
  176.             _Last += _M; }}
  177.     void insert(iterator _P, _It _F, _It _L)
  178.         {size_type _M = 0;
  179.         _Distance(_F, _L, _M);
  180.         if (_End - _Last < _M)
  181.             {size_type _N = size() + (_M < size() ? size() : _M);
  182.             iterator _S = allocator.allocate(_N, (void *)0);
  183.             iterator _Q = _Ucopy(_First, _P, _S);
  184.             _Q = _Ucopy(_F, _L, _Q);
  185.             _Ucopy(_P, _Last, _Q);
  186.             _Destroy(_First, _Last);
  187.             allocator.deallocate(_First, _End - _First);
  188.             _End = _S + _N;
  189.             _Last = _S + size() + _M;
  190.             _First = _S; }
  191.         else if (_Last - _P < _M)
  192.             {_Ucopy(_P, _Last, _P + _M);
  193.             _Ucopy(_F + (_Last - _P), _L, _Last);
  194.             copy(_F, _F + (_Last - _P), _P);
  195.             _Last += _M; }
  196.         else if (0 < _M)
  197.             {_Ucopy(_Last - _M, _Last, _Last);
  198.             copy_backward(_P, _Last - _M, _Last);
  199.             copy(_F, _L, _P);
  200.             _Last += _M; }}
  201.     iterator erase(iterator _P)
  202.         {copy(_P + 1, end(), _P);
  203.         _Destroy(_Last - 1, _Last);
  204.         --_Last;
  205.         return (_P); }
  206.     iterator erase(iterator _F, iterator _L)
  207.         {iterator _S = copy(_L, end(), _F);
  208.         _Destroy(_S, end());
  209.         _Last = _S;
  210.         return (_F); }
  211.     void clear()
  212.         {erase(begin(), end()); }
  213.     bool _Eq(const _Myt& _X) const
  214.         {return (size() == _X.size()
  215.             && equal(begin(), end(), _X.begin())); }
  216.     bool _Lt(const _Myt& _X) const
  217.         {return (lexicographical_compare(begin(), end(),
  218.             _X.begin(), _X.end())); }
  219.     void swap(_Myt& _X)
  220.         {if (allocator == _X.allocator)
  221.             {std::swap(_First, _X._First);
  222.             std::swap(_Last, _X._Last);
  223.             std::swap(_End, _X._End); }
  224.         else
  225.             {_Myt _Ts = *this; *this = _X, _X = _Ts; }}
  226.     friend void swap(_Myt& _X, _Myt& _Y)
  227.         {_X.swap(_Y); }
  228. protected:
  229.     void _Destroy(iterator _F, iterator _L)
  230.         {for (; _F != _L; ++_F)
  231.             allocator.destroy(_F); }
  232.     iterator _Ucopy(const_iterator _F, const_iterator _L,
  233.         iterator _P)
  234.         {for (; _F != _L; ++_P, ++_F)
  235.             allocator.construct(_P, *_F);
  236.         return (_P); }
  237.     void _Ufill(iterator _F, size_type _N, const _Ty &_X)
  238.         {for (; 0 < _N; --_N, ++_F)
  239.             allocator.construct(_F, _X); }
  240.     void _Xran() const
  241.         {_THROW(out_of_range, "invalid vector<T> subscript"); }
  242.     _A allocator;
  243.     iterator _First, _Last, _End;
  244.     };
  245.         // CLASS vector<_Bool, allocator>
  246. typedef unsigned int _Vbase;
  247. const int _VBITS = CHAR_BIT * sizeof (_Vbase);
  248. typedef allocator<_Vbase> _Bool_allocator;
  249. class vector<_Bool, _Bool_allocator> {
  250. public:
  251.     typedef _Bool_allocator _A;
  252.     typedef _Bool _Ty;
  253.     typedef vector<_Ty, _A> _Myt;
  254.     typedef vector<_Vbase, _A> _Vbtype;
  255.     typedef _A allocator_type;
  256.     typedef _A::size_type size_type;
  257.     typedef _A::difference_type difference_type;
  258.  
  259.         // CLASS reference
  260.     class reference {
  261.     public:
  262.         reference()
  263.             : _Mask(0), _Ptr(0) {}
  264.         reference(size_t _O, _Vbase *_P)
  265.             : _Mask((_Vbase)1 << _O), _Ptr(_P) {}
  266.         reference& operator=(const reference& _X)
  267.             {return (*this = bool(_X)); }
  268.         reference& operator=(bool _V)
  269.             {if (_V)
  270.                 *_Ptr |= _Mask;
  271.             else
  272.                 *_Ptr &= ~_Mask;
  273.             return (*this); }
  274.         void flip()
  275.             {*_Ptr ^= _Mask; }
  276.         bool operator~() const
  277.             {return (!bool(*this)); }
  278.         operator bool() const
  279.             {return ((*_Ptr & _Mask) != 0); }
  280.     protected:
  281.         _Vbase _Mask, *_Ptr;
  282.         };
  283.  
  284.     typedef const reference const_reference;
  285.     typedef bool value_type;
  286.         // CLASS const_iterator
  287.     class iterator;
  288.     class const_iterator : public _Ranit<_Bool, difference_type> {
  289.     public:
  290.         const_iterator()
  291.             : _Off(0), _Ptr(0) {}
  292.         const_iterator(size_t _O, const _Vbase *_P)
  293.             : _Off(_O), _Ptr((_Vbase*)_P) {}
  294.         const_iterator(const iterator& _X)
  295.             : _Off(_X._Off), _Ptr(_X._Ptr) {}
  296.         const_reference operator*() const
  297.             {return (const_reference(_Off, _Ptr)); }
  298.         const_iterator& operator++()
  299.             {_Inc();
  300.             return (*this); }
  301.         const_iterator operator++(int)
  302.             {const_iterator _Tmp = *this;
  303.             _Inc();
  304.             return (_Tmp); }
  305.         const_iterator& operator--()
  306.             {_Dec();
  307.             return (*this); }
  308.         const_iterator operator--(int)
  309.             {const_iterator _Tmp = *this;
  310.             _Dec();
  311.             return (_Tmp); }
  312.         const_iterator& operator+=(difference_type _N)
  313.             {_Off += _N;
  314.             _Ptr += _Off / _VBITS;
  315.             _Off %= _VBITS;
  316.             return (*this); }
  317.         const_iterator& operator-=(difference_type _N)
  318.             {return (*this += -_N); }
  319.         const_iterator operator+(difference_type _N) const
  320.             {const_iterator _Tmp = *this;
  321.             return (_Tmp += _N); }
  322.         const_iterator operator-(difference_type _N) const
  323.             {const_iterator _Tmp = *this;
  324.             return (_Tmp -= _N); }
  325.         difference_type operator-(const const_iterator _X) const
  326.             {return (_VBITS * (_Ptr - _X._Ptr)
  327.                 + (difference_type)_Off
  328.                 - (difference_type)_X._Off); }
  329.         const_reference operator[](difference_type _N) const
  330.             {return (*(*this + _N)); }
  331.         bool operator==(const const_iterator& _X) const
  332.             {return (_Ptr == _X._Ptr && _Off == _X._Off); }
  333.         bool operator!=(const const_iterator& _X) const
  334.             {return (!(*this == _X)); }
  335.         bool operator<(const const_iterator& _X) const
  336.             {return (_Ptr < _X._Ptr
  337.                 || _Ptr == _X._Ptr && _Off < _X._Off); }
  338.         bool operator>(const const_iterator& _X) const
  339.             {return (_X < *this); }
  340.         bool operator<=(const const_iterator& _X) const
  341.             {return (!(_X < *this)); }
  342.         bool operator>=(const const_iterator& _X) const
  343.             {return (!(*this < _X)); }
  344.     protected:
  345.         void _Dec()
  346.             {if (_Off != 0)
  347.                 --_Off;
  348.             else
  349.                 _Off = _VBITS - 1, --_Ptr; }
  350.         void _Inc()
  351.             {if (_Off < _VBITS - 1)
  352.                 ++_Off;
  353.             else
  354.                 _Off = 0, ++_Ptr; }
  355.         size_t _Off;
  356.         _Vbase *_Ptr;
  357.         };
  358.         // CLASS iterator
  359.     class iterator : public const_iterator {
  360.     public:
  361.         iterator()
  362.             : const_iterator() {}
  363.         iterator(size_t _O, _Vbase *_P)
  364.             : const_iterator(_O, _P) {}
  365.         reference operator*() const
  366.             {return (reference(_Off, _Ptr)); }
  367.         iterator& operator++()
  368.             {_Inc();
  369.             return (*this); }
  370.         iterator operator++(int)
  371.             {iterator _Tmp = *this;
  372.             _Inc();
  373.             return (_Tmp); }
  374.         iterator& operator--()
  375.             {_Dec();
  376.             return (*this); }
  377.         iterator operator--(int)
  378.             {iterator _Tmp = *this;
  379.             _Dec();
  380.             return (_Tmp); }
  381.         iterator& operator+=(difference_type _N)
  382.             {_Off += _N;
  383.             _Ptr += _Off / _VBITS;
  384.             _Off %= _VBITS;
  385.             return (*this); }
  386.         iterator& operator-=(difference_type _N)
  387.             {return (*this += -_N); }
  388.         iterator operator+(difference_type _N) const
  389.             {iterator _Tmp = *this;
  390.             return (_Tmp += _N); }
  391.         iterator operator-(difference_type _N) const
  392.             {iterator _Tmp = *this;
  393.             return (_Tmp -= _N); }
  394.         difference_type operator-(const iterator _X) const
  395.             {return (_VBITS * (_Ptr - _X._Ptr)
  396.                 + (difference_type)_Off
  397.                 - (difference_type)_X._Off); }
  398.         reference operator[](difference_type _N) const
  399.             {return (*(*this + _N)); }
  400.         bool operator==(const iterator& _X) const
  401.             {return (_Ptr == _X._Ptr && _Off == _X._Off); }
  402.         bool operator!=(const iterator& _X) const
  403.             {return (!(*this == _X)); }
  404.         bool operator<(const iterator& _X) const
  405.             {return (_Ptr < _X._Ptr
  406.                 || _Ptr == _X._Ptr && _Off < _X._Off); }
  407.         bool operator>(const iterator& _X) const
  408.             {return (_X < *this); }
  409.         bool operator<=(const iterator& _X) const
  410.             {return (!(_X < *this)); }
  411.         bool operator>=(const iterator& _X) const
  412.             {return (!(*this < _X)); }
  413.         };
  414.     typedef reverse_iterator<const_iterator, value_type,
  415.         const_reference, const_reference *, difference_type>
  416.             const_reverse_iterator;
  417.     typedef reverse_iterator<iterator, value_type,
  418.         reference, reference *, difference_type>
  419.             reverse_iterator;
  420.     explicit vector(const _A& _Al = _A())
  421.         : _Size(0), _Vec(_Al) {}
  422.     explicit vector(size_type _N, const bool _V = false,
  423.         const _A& _Al = _A())
  424.         : _Vec(_Nw(_N), _V ? -1 : 0, _Al) {_Trim(_N); }
  425.     typedef const_iterator _It;
  426.     vector(_It _F, _It _L, const _A& _Al = _A())
  427.         : _Size(0), _Vec(_Al)
  428.         {insert(begin(), _F, _L); }
  429.     ~vector()
  430.         {_Size = 0; }
  431.     void reserve(size_type _N)
  432.         {_Vec.reserve(_Nw(_N)); }
  433.     size_type capacity() const
  434.         {return (_Vec.capacity() * _VBITS); }
  435.     iterator begin()
  436.         {return (iterator(0, _Vec.begin())); }
  437.     const_iterator begin() const
  438.         {return (const_iterator(0, _Vec.begin())); }
  439.     iterator end()
  440.         {iterator _Tmp = begin();
  441.         if (0 < _Size)
  442.             _Tmp += _Size;
  443.         return (_Tmp); }
  444.     const_iterator end() const
  445.         {const_iterator _Tmp = begin();
  446.         if (0 < _Size)
  447.             _Tmp += _Size;
  448.         return (_Tmp); }
  449.     reverse_iterator rbegin()
  450.         {return (reverse_iterator(end())); }
  451.     const_reverse_iterator rbegin() const
  452.         {return (const_reverse_iterator(end())); }
  453.     reverse_iterator rend()
  454.         {return (reverse_iterator(begin())); }
  455.     const_reverse_iterator rend() const
  456.         {return (const_reverse_iterator(begin())); }
  457.     void resize(size_type _N, bool _X = false)
  458.         {if (size() < _N)
  459.             insert(end(), _N - size(), _X);
  460.         else if (_N < size())
  461.             erase(begin() + _N, end()); }
  462.     size_type size() const
  463.         {return (_Size); }
  464.     size_type max_size() const
  465.         {return (_Vec.max_size() * _VBITS); }
  466.     bool empty() const
  467.         {return (size() == 0); }
  468.     _A get_allocator() const
  469.         {return (_Vec.get_allocator()); }
  470.     const_reference at(size_type _P) const
  471.         {if (size() <= _P)
  472.             _Xran();
  473.         return (*(begin() + _P)); }
  474.     reference at(size_type _P)
  475.         {if (size() <= _P)
  476.             _Xran();
  477.         return (*(begin() + _P)); }
  478.     const_reference operator[](size_type _P) const
  479.         {return (*(begin() + _P)); }
  480.     reference operator[](size_type _P)
  481.         {return (*(begin() + _P)); }
  482.     reference front()
  483.         {return (*begin()); }
  484.     const_reference front() const
  485.         {return (*begin()); }
  486.     reference back()
  487.         {return (*(end() - 1)); }
  488.     const_reference back() const
  489.         {return (*(end() - 1)); }
  490.     void push_back(const bool _X)
  491.         {insert(end(), _X); }
  492.     void pop_back()
  493.         {erase(end() - 1); }
  494.     void assign(_It _F, _It _L)
  495.         {erase(begin(), end());
  496.         insert(begin(), _F, _L); }
  497.     void assign(size_type _N, const bool _X = false)
  498.         {erase(begin(), end());
  499.         insert(begin(), _N, _X); }
  500.     iterator insert(iterator _P, const bool _X = false)
  501.         {size_type _O = _P - begin();
  502.         insert(_P, 1, _X);
  503.         return (begin() + _O); }
  504.     void insert(iterator _P, size_type _M, const bool _X)
  505.         {if (0 < _M)
  506.             {if (capacity() - size() < _M)
  507.                 {size_type _O = _P - begin();
  508.                 _Vec.resize(_Nw(size() + _M), 0);
  509.                 _P = begin() + _O; }
  510.             copy_backward(_P, end(), end() + _M);
  511.             fill(_P, _P + _M, _X);
  512.             _Size += _M; }}
  513.     void insert(iterator _P, _It _F, _It _L)
  514.         {size_type _M = 0;
  515.         _Distance(_F, _L, _M);
  516.         if (0 < _M)
  517.             {if (capacity() - size() < _M)
  518.                 {size_type _O = _P - begin();
  519.                 _Vec.resize(_Nw(size() + _M), 0);
  520.                 _P = begin() + _O; }
  521.             copy_backward(_P, end(), end() + _M);
  522.             copy(_F, _L, _P);
  523.             _Size += _M; }}
  524.     iterator erase(iterator _P)
  525.         {copy(_P + 1, end(), _P);
  526.         _Trim(_Size - 1);
  527.         return (_P); }
  528.     iterator erase(iterator _F, iterator _L)
  529.         {iterator _S = copy(_L, end(), _F);
  530.         _Trim(_S - begin());
  531.         return (_F); }
  532.     void clear()
  533.         {erase(begin(), end()); }
  534.     void flip()
  535.         {for (_Vbtype::iterator _S = _Vec.begin();
  536.             _S != _Vec.end(); ++_S)
  537.             *_S = ~*_S;
  538.         _Trim(_Size); }
  539.     bool _Eq(const _Myt& _X) const
  540.         {return (_Size == _X._Size && _Vec._Eq(_X._Vec)); }
  541.     bool _Lt(const _Myt& _X) const
  542.         {return (_Size < _X._Size
  543.             || _Size == _X._Size && _Vec._Lt(_X._Vec)); }
  544.     void swap(_Myt& _X)
  545.         {std::swap(_Size, _X._Size);
  546.         _Vec.swap(_X._Vec); }
  547.     friend void swap(_Myt& _X, _Myt& _Y)
  548.         {_X.swap(_Y); }
  549.     static void swap(reference _X, reference _Y)
  550.         {bool _V = _X;
  551.         _X = _Y;
  552.         _Y = _V; }
  553. protected:
  554.     static size_type _Nw(size_type _N)
  555.         {return ((_N + _VBITS - 1) / _VBITS); }
  556.     void _Trim(size_type _N)
  557.         {size_type _M = _Nw(_N);
  558.         if (_M < _Vec.size())
  559.             _Vec.erase(_Vec.begin() + _M, _Vec.end());
  560.         _Size = _N;
  561.         _N %= _VBITS;
  562.         if (0 < _N)
  563.             _Vec[_M - 1] &= ((_Vbase)1 << _N) - 1; }
  564.     void _Xran() const
  565.         {_THROW(out_of_range, "invalid vector<bool> subscript"); }
  566.     size_type _Size;
  567.     _Vbtype _Vec;
  568.     };
  569. typedef vector<_Bool, _Bool_allocator> _Bvector;
  570.         // vector TEMPLATE OPERATORS
  571. template<class _Ty, class _A> inline
  572.     bool operator==(const vector<_Ty, _A>& _X,
  573.         const vector<_Ty, _A>& _Y)
  574.     {return (_X._Eq(_Y)); }
  575. template<class _Ty, class _A> inline
  576.     bool operator!=(const vector<_Ty, _A>& _X,
  577.         const vector<_Ty, _A>& _Y)
  578.     {return (!(_X == _Y)); }
  579. template<class _Ty, class _A> inline
  580.     bool operator<(const vector<_Ty, _A>& _X,
  581.         const vector<_Ty, _A>& _Y)
  582.     {return (_X._Lt(_Y)); }
  583. template<class _Ty, class _A> inline
  584.     bool operator>(const vector<_Ty, _A>& _X,
  585.         const vector<_Ty, _A>& _Y)
  586.     {return (_Y < _X); }
  587. template<class _Ty, class _A> inline
  588.     bool operator<=(const vector<_Ty, _A>& _X,
  589.         const vector<_Ty, _A>& _Y)
  590.     {return (!(_Y < _X)); }
  591. template<class _Ty, class _A> inline
  592.     bool operator>=(const vector<_Ty, _A>& _X,
  593.         const vector<_Ty, _A>& _Y)
  594.     {return (!(_X < _Y)); }
  595. _STD_END
  596. #ifdef  _MSC_VER
  597. #pragma pack(pop)
  598. #endif  /* _MSC_VER */
  599.  
  600. #endif /* _VECTOR_ */
  601.  
  602. /*
  603.  * Copyright (c) 1995 by P.J. Plauger.  ALL RIGHTS RESERVED. 
  604.  * Consult your license regarding permissions and restrictions.
  605.  */
  606.  
  607. /*
  608.  * This file is derived from software bearing the following
  609.  * restrictions:
  610.  *
  611.  * Copyright (c) 1994
  612.  * Hewlett-Packard Company
  613.  *
  614.  * Permission to use, copy, modify, distribute and sell this
  615.  * software and its documentation for any purpose is hereby
  616.  * granted without fee, provided that the above copyright notice
  617.  * appear in all copies and that both that copyright notice and
  618.  * this permission notice appear in supporting documentation.
  619.  * Hewlett-Packard Company makes no representations about the
  620.  * suitability of this software for any purpose. It is provided
  621.  * "as is" without express or implied warranty.
  622.  */
  623.