|
|
|
|
| #ifndef _CLI_UTILITY_
|
| #define _CLI_UTILITY_
|
|
|
| #include <cliext/xutility>
|
|
|
| namespace cliext {
|
|
|
|
|
|
|
| template<typename _Value1_t,
|
| typename _Value2_t>
|
| ref class pair
|
| {
|
| public:
|
| typedef pair<_Value1_t, _Value2_t> _Mytype_t;
|
| typedef typename _Value1_t first_type;
|
| typedef typename _Value2_t second_type;
|
|
|
|
|
| pair()
|
| {
|
| }
|
|
|
| pair(pair% _Right)
|
| : first(_Right.first), second(_Right.second)
|
| {
|
| }
|
|
|
| pair(pair^ _Right)
|
| : first(_Right->first), second(_Right->second)
|
| {
|
| }
|
|
|
| pair% operator=(pair% _Right)
|
| {
|
| first = _Right.first;
|
| second = _Right.second;
|
| return (*this);
|
| }
|
|
|
| pair% operator=(pair^ _Right)
|
| {
|
| first = _Right->first;
|
| second = _Right->second;
|
| return (*this);
|
| }
|
|
|
|
|
| pair(first_type _Val1)
|
| : first(_Val1)
|
| {
|
| }
|
|
|
| pair(first_type _Val1, second_type _Val2)
|
| : first(_Val1), second(_Val2)
|
| {
|
| }
|
|
|
| template<typename _Pair_t>
|
| pair(_Pair_t% _Right)
|
| : first(_Right.first), second(_Right.second)
|
| {
|
| }
|
|
|
| template<typename _Pair_t>
|
| pair(_Pair_t^ _Right)
|
| : first(_Right->first), second(_Right->second)
|
| {
|
| }
|
|
|
| template<template <class, class> class _Pair_t, typename _OtherFirst_t, typename _OtherSecond_t>
|
| operator _Pair_t<_OtherFirst_t, _OtherSecond_t>()
|
| {
|
| _Pair_t<_OtherFirst_t, _OtherSecond_t> _Newpair((_OtherFirst_t)first,(_OtherSecond_t)second);
|
|
|
| return (_Newpair);
|
| }
|
|
|
|
|
| void swap(pair% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Value1_t _Tfirst = first;
|
| _Value2_t _Tsecond = second;
|
|
|
| first = _Right.first;
|
| _Right.first = _Tfirst;
|
|
|
| second = _Right.second;
|
| _Right.second = _Tsecond;
|
| }
|
| }
|
|
|
| first_type first;
|
| second_type second;
|
| };
|
|
|
|
|
|
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| void swap(pair<_Ty1, _Ty2>% _Left, pair<_Ty1, _Ty2>% _Right)
|
| {
|
| _Left.swap(_Right);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator==(pair<_Ty1, _Ty2>% _Left,
|
| pair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (_Left.first == _Right.first && _Left.second == _Right.second);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator!=(pair<_Ty1, _Ty2>% _Left,
|
| pair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (!(_Left == _Right));
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator<(pair<_Ty1, _Ty2>% _Left,
|
| pair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (_Left.first < _Right.first ||
|
| !(_Right.first < _Left.first) && _Left.second < _Right.second);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator>(pair<_Ty1, _Ty2>% _Left,
|
| pair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (_Right < _Left);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator<=(pair<_Ty1, _Ty2>% _Left,
|
| pair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (!(_Right < _Left));
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator>=(pair<_Ty1, _Ty2>% _Left,
|
| pair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (!(_Left < _Right));
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| pair<_Ty1, _Ty2> make_pair(_Ty1 _Val1, _Ty2 _Val2)
|
| {
|
| return (pair<_Ty1, _Ty2>(_Val1, _Val2));
|
| }
|
|
|
|
|
|
|
|
|
| template<typename _Value1_t,
|
| typename _Value2_t>
|
| value class light_pair
|
| {
|
| public:
|
| typedef light_pair<_Value1_t, _Value2_t> _Mytype_t;
|
| typedef typename _Value1_t first_type;
|
| typedef typename _Value2_t second_type;
|
|
|
|
|
| light_pair(first_type _Val1)
|
| : first(_Val1)
|
| {
|
| }
|
|
|
| light_pair(first_type _Val1, second_type _Val2)
|
| : first(_Val1), second(_Val2)
|
| {
|
| }
|
|
|
| template<typename _Pair_t>
|
| light_pair(_Pair_t% _Right)
|
| : _First(_Right.first), _Second(_Right.second)
|
| {
|
| }
|
|
|
| template<template <class, class> class _Pair_t, typename _OtherFirst_t, typename _OtherSecond_t>
|
| operator _Pair_t<_OtherFirst_t, _OtherSecond_t>()
|
| {
|
| _Pair_t<_OtherFirst_t, _OtherSecond_t> _Newpair((_OtherFirst_t)first,(_OtherSecond_t)second);
|
|
|
| return (_Newpair);
|
| }
|
|
|
|
|
| void swap(light_pair% _Right)
|
| {
|
| if ((System::Object^)this != %_Right)
|
| {
|
| _Value1_t _Tfirst = first;
|
| _Value2_t _Tsecond = second;
|
|
|
| first = _Right.first;
|
| _Right.first = _Tfirst;
|
|
|
| second = _Right.second;
|
| _Right.second = _Tsecond;
|
| }
|
| }
|
|
|
| first_type first;
|
| second_type second;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Value1_t,
|
| typename _Value2_t,
|
| bool _Is_ref =
|
| __is_ref_class(typename _Dehandle<_Value1_t>::type)
|
| && !is_handle<_Value1_t>::value
|
| && __is_ref_class(typename _Dehandle<_Value2_t>::type)
|
| && !is_handle<_Value2_t>::value>
|
| ref class select_pair
|
| {
|
| public:
|
| typedef pair<_Value1_t, _Value2_t> type;
|
| };
|
|
|
| template<typename _Value1_t,
|
| typename _Value2_t>
|
| ref class select_pair<_Value1_t, _Value2_t, false>
|
| {
|
| public:
|
| typedef light_pair<_Value1_t, _Value2_t> type;
|
| };
|
|
|
|
|
|
|
|
|
| template<typename _Value_t>
|
| bool operator==(System::IComparable<_Value_t>^ _Left,
|
| System::IComparable<_Value_t>^ _Right)
|
| {
|
| return (_Left->CompareTo(_Right) == 0);
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator!=(System::IComparable<_Value_t>^ _Left,
|
| System::IComparable<_Value_t>^ _Right)
|
| {
|
| return (!(_Left == _Right));
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator<(System::IComparable<_Value_t>^ _Left,
|
| System::IComparable<_Value_t>^ _Right)
|
| {
|
| return (_Left->CompareTo(_Right) < 0);
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator>=(System::IComparable<_Value_t>^ _Left,
|
| System::IComparable<_Value_t>^ _Right)
|
| {
|
| return (!(_Left < _Right));
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator>(System::IComparable<_Value_t>^ _Left,
|
| System::IComparable<_Value_t>^ _Right)
|
| {
|
| return (_Right < _Left);
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator<=(System::IComparable<_Value_t>^ _Left,
|
| System::IComparable<_Value_t>^ _Right)
|
| {
|
| return (!(_Right < _Left));
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator==(System::IComparable<_Value_t>% _Left,
|
| System::IComparable<_Value_t>% _Right)
|
| {
|
| return (_Left.CompareTo((_Value_t)%(System::Object%)_Right) == 0);
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator!=(System::IComparable<_Value_t>% _Left,
|
| System::IComparable<_Value_t>% _Right)
|
| {
|
| return (!(_Left == _Right));
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator<(System::IComparable<_Value_t>% _Left,
|
| System::IComparable<_Value_t>% _Right)
|
| {
|
| return (_Left.CompareTo((_Value_t)%(System::Object%)_Right) < 0);
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator>=(System::IComparable<_Value_t>% _Left,
|
| System::IComparable<_Value_t>% _Right)
|
| {
|
| return (!(_Left < _Right));
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator>(System::IComparable<_Value_t>% _Left,
|
| System::IComparable<_Value_t>% _Right)
|
| {
|
| return (_Right < _Left);
|
| }
|
|
|
| template<typename _Value_t>
|
| bool operator<=(System::IComparable<_Value_t>% _Left,
|
| System::IComparable<_Value_t>% _Right)
|
| {
|
| return (!(_Right < _Left));
|
| }
|
|
|
| inline bool operator==(System::IComparable^ _Left,
|
| System::IComparable^ _Right)
|
| {
|
| return (_Left->CompareTo(_Right) == 0);
|
| }
|
|
|
| inline bool operator!=(System::IComparable^ _Left,
|
| System::IComparable^ _Right)
|
| {
|
| return (!(_Left == _Right));
|
| }
|
|
|
| inline bool operator<(System::IComparable^ _Left,
|
| System::IComparable^ _Right)
|
| {
|
| return (_Left->CompareTo(_Right) < 0);
|
| }
|
|
|
| inline bool operator>=(System::IComparable^ _Left,
|
| System::IComparable^ _Right)
|
| {
|
| return (!(_Left < _Right));
|
| }
|
|
|
| inline bool operator>(System::IComparable^ _Left,
|
| System::IComparable^ _Right)
|
| {
|
| return (_Right < _Left);
|
| }
|
|
|
| inline bool operator<=(System::IComparable^ _Left,
|
| System::IComparable^ _Right)
|
| {
|
| return (!(_Right < _Left));
|
| }
|
|
|
| inline bool operator==(System::IComparable% _Left,
|
| System::IComparable% _Right)
|
| {
|
| return (_Left.CompareTo(%(System::Object%)_Right) == 0);
|
| }
|
|
|
| inline bool operator!=(System::IComparable% _Left,
|
| System::IComparable% _Right)
|
| {
|
| return (!(_Left == _Right));
|
| }
|
|
|
| inline bool operator<(System::IComparable% _Left,
|
| System::IComparable% _Right)
|
| {
|
| return (_Left.CompareTo(%(System::Object%)_Right) < 0);
|
| }
|
|
|
| inline bool operator>=(System::IComparable% _Left,
|
| System::IComparable% _Right)
|
| {
|
| return (!(_Left < _Right));
|
| }
|
|
|
| inline bool operator>(System::IComparable% _Left,
|
| System::IComparable% _Right)
|
| {
|
| return (_Right < _Left);
|
| }
|
|
|
| inline bool operator<=(System::IComparable% _Left,
|
| System::IComparable% _Right)
|
| {
|
| return (!(_Right < _Left));
|
| }
|
| }
|
| using cliext::operator==;
|
| using cliext::operator!=;
|
| using cliext::operator<;
|
| using cliext::operator>=;
|
| using cliext::operator>;
|
| using cliext::operator<=;
|
|
|
| namespace Microsoft {
|
| namespace VisualC {
|
| namespace StlClr {
|
|
|
|
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| void swap(_STLCLR GenericPair<_Ty1, _Ty2>% _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>% _Right)
|
| {
|
| _Left.swap(_Right);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator==(_STLCLR GenericPair<_Ty1, _Ty2>% _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (_Left.first == _Right.first && _Left.second == _Right.second);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator==(_STLCLR GenericPair<_Ty1, _Ty2>^ _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>^ _Right)
|
| {
|
| return (_Left->first == _Right->first
|
| && _Left->second == _Right->second);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator!=(_STLCLR GenericPair<_Ty1, _Ty2>% _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (!(_Left == _Right));
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator<(_STLCLR GenericPair<_Ty1, _Ty2>% _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (_Left.first < _Right.first ||
|
| !(_Right.first < _Left.first) && _Left.second < _Right.second);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator<(_STLCLR GenericPair<_Ty1, _Ty2>^ _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>^ _Right)
|
| {
|
| return (_Left->first < _Right->first ||
|
| !(_Right->first < _Left->first) && _Left->second < _Right->second);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator>(_STLCLR GenericPair<_Ty1, _Ty2>% _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (_Right < _Left);
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator<=(_STLCLR GenericPair<_Ty1, _Ty2>% _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (!(_Right < _Left));
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| bool operator>=(_STLCLR GenericPair<_Ty1, _Ty2>% _Left,
|
| _STLCLR GenericPair<_Ty1, _Ty2>% _Right)
|
| {
|
| return (!(_Left < _Right));
|
| }
|
|
|
| template<class _Ty1,
|
| class _Ty2> inline
|
| _STLCLR GenericPair<_Ty1, _Ty2>
|
| make_generic_pair(_Ty1 _Val1, _Ty2 _Val2)
|
| {
|
| return (_STLCLR GenericPair<_Ty1, _Ty2>(_Val1, _Val2));
|
| }
|
| }
|
| }
|
| }
|
| #endif
|
|
|