?? iterator
字號(hào):
#pragma warning(pop)
bool operator==(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
{ // test if *this == _Right
return (equal_to(_Right));
}
bool operator==(_Mytype_t% _Right)
{ // test if *this == _Right
return (equal_to(_Right));
}
bool operator!=(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
{ // test if *this != _Right
return (!(*this == _Right));
}
bool operator!=(_Mytype_t% _Right)
{ // test if *this != _Right
return (!(*this == _Right));
}
#pragma warning(push)
#pragma warning(disable:4460)
static ConstRandomAccessIterator operator--(
ConstRandomAccessIterator% _Left)
{ // return decremented
_Left.prev();
return (_Left);
}
static ConstRandomAccessIterator operator+(
ConstRandomAccessIterator% _Left,
difference_type _Right)
{ // return incremented by integer
ConstRandomAccessIterator _Iter = _Left;
_Iter.move(_Right);
return (_Iter);
}
static ConstRandomAccessIterator operator+(
difference_type _Left,
ConstRandomAccessIterator _Right)
{ // return incremented by integer
ConstRandomAccessIterator _Iter = _Right;
_Iter.move(_Left);
return (_Iter);
}
static ConstRandomAccessIterator operator-(
ConstRandomAccessIterator% _Left,
difference_type _Right)
{ // return decremented by integer
ConstRandomAccessIterator _Iter = _Left;
_Iter.move(-_Right); // can overflow
return (_Iter);
}
difference_type operator-(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right)
{ // return difference of two iterators
return (distance(_Right));
}
bool operator<(_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right)
{ // test if *this < _Right
return (less_than(_Right));
}
bool operator<(_Mytype_t% _Right)
{ // test if *this < _Right
return (less_than(_Right));
}
bool operator>=(_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right)
{ // test if *this >= _Right
return (!(*this < _Right));
}
bool operator>=(_Mytype_t% _Right)
{ // test if *this >= _Right
return (!(*this < _Right));
}
static bool operator>(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Left,
_Mytype_t% _Right)
{ // test if _Left > _Right
return (_Right < _Left);
}
bool operator>(_Mytype_t%_Right)
{ // test if *this > _Right
return (_Right < *this);
}
static bool operator<=(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Left,
_Mytype_t% _Right)
{ // test if _Left <= _Right
return (!(_Right < _Left));
}
bool operator<=(_Mytype_t%_Right)
{ // test if *this <= _Right
return (!(_Right < *this));
}
property const_reference default[difference_type]
{ // get subscripted element
const_reference get(difference_type _Pos)
{ // get _Pos element
ConstRandomAccessIterator _Where = *this + _Pos;
return (*_Where);
}
};
_STLCLR_FIELD_ACCESS:
// data members
_Cont_t^ _Mycont; // owning container
difference_type _Myoffset; // offset into container
private:
virtual int get_bias_virtual() sealed
= _Myiter_t::get_bias
{ // get offset from wrapped iterator
return (get_bias());
}
virtual System::Object^ get_node_virtual() sealed
= _Myiter_t::get_node
{ // get node from wrapped iterator
return (get_node());
}
virtual bool valid_virtual() sealed
= _Myiter_t::valid
{ // test if iterator valid
return (valid());
}
virtual System::Object^ container_virtual() sealed
= _Myiter_t::container
{ // return owning container
return (container());
}
virtual void next_virtual() sealed
= _Myiter_t::next
{ // increment
next();
}
virtual bool equal_to_virtual(
_STLCLR Generic::IInputIterator<_Value_t>^ _Right) sealed
= _Myiter_t::equal_to
{ // test if *this == _Right
return (equal_to(_Right));
}
virtual const_reference get_cref_virtual() sealed
= _Myiter_t::get_cref
{ // return const reference to designated element
return (get_cref());
}
virtual reference get_ref_virtual() sealed
= _Myiter_t::get_ref
{ // return reference to designated element
#pragma warning(push)
#pragma warning(disable: 4715)
throw gcnew System::InvalidOperationException();
#pragma warning(pop)
}
virtual void prev_virtual() sealed
= _Myiter_t::prev
{ // decrement
prev();
}
virtual difference_type move_virtual(difference_type _Offset) sealed
= _Myiter_t::move
{ // incremented by integer
return (move(_Offset));
}
virtual difference_type distance_virtual(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right) sealed
= _Myiter_t::distance
{ // return difference of two iterators
return (distance(_Right));
}
virtual bool less_than_virtual(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right) sealed
= _Myiter_t::less_than
{ // test if *this < _Right
return (less_than(_Right));
}
};
//
// TEMPLATE VALUE CLASS ConstUncheckedRandomAccessIterator
//
template<typename _Cont_t>
value class ConstUncheckedRandomAccessIterator
: public _STLCLR Generic::IRandomAccessIterator<
typename _Cont_t::value_type>
{ // iterator for nonmutable random-access container
public:
// types
typedef typename _Cont_t::value_type _Value_t;
typedef ConstUncheckedRandomAccessIterator<_Cont_t> _Mytype_t;
typedef _STLCLR Generic::IRandomAccessIterator<_Value_t> _Myiter_t;
typedef random_access_iterator_tag iterator_category;
typedef _Value_t value_type;
typedef int difference_type;
typedef value_type% pointer;
typedef value_type% reference;
typedef value_type% const_reference;
// constructors and special members
ConstUncheckedRandomAccessIterator(_Cont_t^ _Cont, int _Offset)
: _Mycont(_Cont), _Myoffset(_Offset)
{ // construct from container pointer and offset
}
operator ConstRandomAccessIterator<_Cont_t>()
{ // convert to checked iterator
return (ConstRandomAccessIterator<_Cont_t>(_Mycont, _Myoffset));
}
// generic conversions
typedef _STLCLR Generic::ConstContainerRandomAccessIterator<_Value_t>
_Mygeniter_t;
ConstUncheckedRandomAccessIterator(_Mygeniter_t% _Right)
: _Mycont((_Cont_t^)_Right.container()),
_Myoffset(_Right.get_bias())
{ // construct by copying a generic iterator
}
operator _Mygeniter_t()
{ // convert to generic iterator
return (_Mygeniter_t(_Mycont, _Myoffset));
}
// member functions
virtual System::Object^ Clone()
{ // return a copy
return (gcnew ConstUncheckedRandomAccessIterator(_Mycont, _Myoffset));
}
int get_bias()
{ // get offset from wrapped iterator
return (_Myoffset);
}
System::Object^ get_node()
{ // get node from wrapped iterator
return (nullptr);
}
bool valid()
{ // test if iterator valid
return (true); // UNCHECKED
// return (container() != nullptr
// && _Mycont->valid_bias(_Myoffset));
}
System::Object^ container()
{ // return owning container
return (_Mycont);
}
void next()
{ // increment
// if (!_Mycont->valid_bias(_Myoffset + 1)) // UNCHECKED
// throw gcnew System::InvalidOperationException();
++_Myoffset;
}
bool equal_to(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
{ // test if *this == _Right
// if (container() == nullptr // UNCHECKED
// || container() != _Right->container())
// throw gcnew System::ArgumentException();
return (get_bias() == _Right->get_bias()
&& get_node() == _Right->get_node());
}
bool equal_to(_Mytype_t% _Right)
{ // test if *this == _Right
// if (container() == nullptr // UNCHECKED
// || container() != _Right.container())
// throw gcnew System::ArgumentException();
return (get_bias() == _Right.get_bias()
&& get_node() == _Right.get_node());
}
const_reference get_cref()
{ // return const reference to designated element
return (_Mycont->at_bias(_Myoffset));
}
reference get_ref()
{ // return reference to designated element
#pragma warning(push)
#pragma warning(disable: 4715)
throw gcnew System::InvalidOperationException();
#pragma warning(pop)
}
void prev()
{ // decrement
// if (!_Mycont->valid_bias(_Myoffset - 1)) // UNCHECKED
// throw gcnew System::InvalidOperationException();
--_Myoffset;
}
difference_type move(difference_type _Offset)
{ // incremented by integer
difference_type _Newoffset = _Myoffset + _Offset; // can overflow
// if (!_Mycont->valid_bias(_Newoffset)) // UNCHECKED
// throw gcnew System::InvalidOperationException();
_Myoffset = _Newoffset;
return (_Myoffset);
}
difference_type distance(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right)
{ // return difference of two iterators
// if (container() == nullptr // UNCHECKED
// || container() != _Right->container())
// throw gcnew System::ArgumentException();
return (get_bias() - _Right->get_bias());
}
difference_type distance(
_Mytype_t% _Right)
{ // return difference of two iterators
// if (container() == nullptr // UNCHECKED
// || container() != _Right->container())
// throw gcnew System::ArgumentException();
return (get_bias() - _Right.get_bias());
}
bool less_than(_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right)
{ // test if *this < _Right
// if (container() == nullptr // UNCHECKED
// || container() != _Right->container())
// throw gcnew System::ArgumentException();
return (get_bias() < _Right->get_bias());
}
bool less_than(_Mytype_t% _Right)
{ // test if *this < _Right
// if (container() == nullptr // UNCHECKED
// || container() != _Right->container())
// throw gcnew System::ArgumentException();
return (get_bias() < _Right.get_bias());
}
// operators
static const_reference operator->(
ConstUncheckedRandomAccessIterator% _Left)
{ // return pointer to class object
return (_Left.get_cref());
}
static const_reference operator*(
ConstUncheckedRandomAccessIterator% _Left)
{ // return const reference to designated element
return (_Left.get_cref());
}
#pragma warning(push)
#pragma warning(disable:4460)
static ConstUncheckedRandomAccessIterator operator++(
ConstUncheckedRandomAccessIterator% _Left)
{ // return incremented
_Left.next();
return (_Left);
}
#pragma warning(pop)
bool operator==(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
{ // test if *this == _Right
return (equal_to(_Right));
}
bool operator==(_Mytype_t% _Right)
{ // test if *this == _Right
return (equal_to(_Right));
}
bool operator!=(_STLCLR Generic::IInputIterator<_Value_t>^ _Right)
{ // test if *this != _Right
return (!(*this == _Right));
}
bool operator!=(_Mytype_t% _Right)
{ // test if *this != _Right
return (!(*this == _Right));
}
#pragma warning(push)
#pragma warning(disable:4460)
static ConstUncheckedRandomAccessIterator operator--(
ConstUncheckedRandomAccessIterator% _Left)
{ // return decremented
_Left.prev();
return (_Left);
}
static ConstUncheckedRandomAccessIterator operator+(
ConstUncheckedRandomAccessIterator% _Left,
difference_type _Right)
{ // return incremented by integer
ConstUncheckedRandomAccessIterator _Iter = _Left;
_Iter.move(_Right);
return (_Iter);
}
static ConstUncheckedRandomAccessIterator operator+(
difference_type _Left,
ConstUncheckedRandomAccessIterator _Right)
{ // return incremented by integer
ConstUncheckedRandomAccessIterator _Iter = _Right;
_Iter.move(_Left);
return (_Iter);
}
static ConstUncheckedRandomAccessIterator operator-(
ConstUncheckedRandomAccessIterator% _Left,
difference_type _Right)
{ // return decremented by integer
ConstUncheckedRandomAccessIterator _Iter = _Left;
_Iter.move(-_Right); // can overflow
return (_Iter);
}
difference_type operator-(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right)
{ // return difference of two iterators
return (distance(_Right));
}
bool operator<(_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right)
{ // test if *this < _Right
return (less_than(_Right));
}
bool operator<(_Mytype_t% _Right)
{ // test if *this < _Right
return (less_than(_Right));
}
bool operator>=(_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Right)
{ // test if *this >= _Right
return (!(*this < _Right));
}
bool operator>=(_Mytype_t% _Right)
{ // test if *this >= _Right
return (!(*this < _Right));
}
static bool operator>(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Left,
_Mytype_t% _Right)
{ // test if _Left > _Right
return (_Right < _Left);
}
bool operator>(_Mytype_t%_Right)
{ // test if *this > _Right
return (_Right < *this);
}
static bool operator<=(
_STLCLR Generic::IRandomAccessIterator<_Value_t>^ _Left,
_Mytype_t% _Right)
{ // test if _Left <= _Right
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -