📄 memory
字号:
int _Maxlen()
{ // return size of buffer
if (_Mycont == nullptr)
{ // allocate buffer and iterator on first size query
_Mycont = gcnew _Mycont_t(_Mysize);
_Next = gcnew iterator;
}
return (_Mycont->size());
}
_STLCLR_FIELD_ACCESS:
int _Mysize; // size of desired buffer
_Mycont_t^ _Mycont; // handle for buffer
iterator^ _Next; // iterator into buffer
};
// ALGORITHM STUFF (from <algorithm>)
// TEMPLATE FUNCTION swap
template<class _Ty> inline
void swap(_Ty% _Left, _Ty% _Right)
{ // exchange values stored at _Left and _Right
_Ty _Tmp = _Left;
_Left = _Right, _Right = _Tmp;
}
// TEMPLATE FUNCTION copy
template<class _InIt,
class _OutIt> inline
_OutIt copy_unchecked(_InIt _First, _InIt _Last, _OutIt _Dest)
{ // copy [_First, _Last) to [_Dest, ...)
for (; _First != _Last; ++_Dest, ++_First)
*_Dest = *_First;
return (_Dest);
}
template<class _InIt,
class _OutIt> inline
_OutIt copy(_InIt _First, _InIt _Last, _OutIt _Dest)
{ // copy [_First, _Last) to [_Dest, ...)
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First, _Last);
if (_First != _Last)
_STLCLRDB_POINTER(_Dest);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (cliext::copy_unchecked(
_Unchecked(_First), _Unchecked(_Last),
_Unchecked(_Dest)));
}
// TEMPLATE FUNCTION copy_backward
template<class _BidIt1,
class _BidIt2> inline
_BidIt2 copy_backward_unchecked(_BidIt1 _First, _BidIt1 _Last,
_BidIt2 _Dest)
{ // copy [_First, _Last) backwards to [..., _Dest)
while (_First != _Last)
*--_Dest = *--_Last;
return (_Dest);
}
template<class _BidIt1,
class _BidIt2> inline
_BidIt2 copy_backward(_BidIt1 _First, _BidIt1 _Last, _BidIt2 _Dest)
{ // copy [_First, _Last) backwards to [..., _Dest)
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First, _Last);
if (_First != _Last)
_STLCLRDB_POINTER(_Dest);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (cliext::copy_backward_unchecked(
_Unchecked(_First), _Unchecked(_Last),
_Unchecked(_Dest)));
}
// TEMPLATE FUNCTION mismatch
template<class _InIt1,
class _InIt2> inline
_PAIR_TYPE2(_InIt1, _InIt2)
mismatch_unchecked(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2)
{ // return [_First1, _Last1) and [_First2, _Last2) mismatch
for (; _First1 != _Last1 && *_First1 == *_First2; )
++_First1, ++_First2;
return (_PAIR_TYPE2(_InIt1, _InIt2)(_First1, _First2));
}
template<class _InIt1,
class _InIt2> inline
_PAIR_TYPE2(_InIt1, _InIt2)
mismatch(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2)
{ // return [_First1, _Last1) and [_First2, _Last2) mismatch
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First1, _Last1);
if (_First1 != _Last1)
_STLCLRDB_POINTER(_First2);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (cliext::mismatch_unchecked(
_Unchecked(_First1), _Unchecked(_Last1),
_Unchecked(_First2)));
}
// TEMPLATE FUNCTION mismatch WITH PRED
template<class _InIt1,
class _InIt2,
class _Pr> inline
_PAIR_TYPE2(_InIt1, _InIt2)
mismatch_unchecked(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2, _Pr _Pred)
{ // return [_First1, _Last1) and [_First2, _Last2) mismatch using _Pred
for (; _First1 != _Last1 && _Pred(*_First1, *_First2); )
++_First1, ++_First2;
return (_PAIR_TYPE2(_InIt1, _InIt2)(_First1, _First2));
}
template<class _InIt1,
class _InIt2,
class _Pr> inline
_PAIR_TYPE2(_InIt1, _InIt2)
mismatch(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2, _Pr _Pred)
{ // return [_First1, _Last1) and [_First2, _Last2) mismatch using _Pred
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First1, _Last1);
if (_First1 != _Last1)
_STLCLRDB_POINTER(_First2);
_STLCLRDB_POINTER(_Pred);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (cliext::mismatch_unchecked(
_Unchecked(_First1), _Unchecked(_Last1),
_Unchecked(_First2), _Pred));
}
// TEMPLATE FUNCTION equal
template<class _InIt1,
class _InIt2> inline
bool equal_unchecked(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2)
{ // compare [_First1, _Last1) to [First2, ...)
for (; _First1 != _Last1; ++_First1, ++_First2)
if (!(*_First1 == *_First2))
return (false);
return (true);
}
template<class _InIt1,
class _InIt2> inline
bool equal(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2)
{ // compare [_First1, _Last1) to [First2, ...)
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First1, _Last1);
if (_First1 != _Last1)
_STLCLRDB_POINTER(_First2);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (cliext::equal_unchecked(
_Unchecked(_First1), _Unchecked(_Last1),
_Unchecked(_First2)));
}
#ifdef _M_CEE_SAFE
#else /* _M_CEE_SAFE */
inline bool equal(const char *_First1, const char *_Last1,
const char *_First2)
{ // compare [_First1, _Last1) to [First2, ...), for chars
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First1, _Last1);
if (_First1 != _Last1)
_STLCLRDB_POINTER(_First2);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (std::memcmp(_First1, _First2, _Last1 - _First1) == 0);
}
inline bool equal(const signed char *_First1, const signed char *_Last1,
const signed char *_First2)
{ // compare [_First1, _Last1) to [First2, ...), for signed chars
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First1, _Last1);
if (_First1 != _Last1)
_STLCLRDB_POINTER(_First2);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (std::memcmp(_First1, _First2, _Last1 - _First1) == 0);
}
inline bool equal(const unsigned char *_First1, const unsigned char *_Last1,
const unsigned char *_First2)
{ // compare [_First1, _Last1) to [First2, ...), for unsigned chars
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First1, _Last1);
if (_First1 != _Last1)
_STLCLRDB_POINTER(_First2);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (std::memcmp(_First1, _First2, _Last1 - _First1) == 0);
}
#endif /* _M_CEE_SAFE */
// TEMPLATE FUNCTION equal WITH PRED
template<class _InIt1,
class _InIt2,
class _Pr> inline
bool equal_unchecked(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2, _Pr _Pred)
{ // compare [_First1, _Last1) to [First2, ...) using _Pred
for (; _First1 != _Last1; ++_First1, ++_First2)
if (!_Pred(*_First1, *_First2))
return (false);
return (true);
}
template<class _InIt1,
class _InIt2,
class _Pr> inline
bool equal(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2, _Pr _Pred)
{ // compare [_First1, _Last1) to [First2, ...) using _Pred
#if _HAS_ITERATOR_DEBUGGING
_STLCLRDB_RANGE(_First1, _Last1);
if (_First1 != _Last1)
_STLCLRDB_POINTER(_First2);
_STLCLRDB_POINTER(_Pred);
#endif /* _HAS_ITERATOR_DEBUGGING */
return (cliext::equal_unchecked(
_Unchecked(_First1), _Unchecked(_Last1),
_Unchecked(_First2), _Pred));
}
// TEMPLATE FUNCTION fill
template<class _FwdIt,
class _Ty> inline
void fill_unchecked(_FwdIt _First, _FwdIt _Last, const _Ty% _Val)
{ // copy _Val through [_First, _Last)
for (; _First != _Last; ++_First)
*_First = _Val;
}
#ifdef _M_CEE_SAFE
#else /* _M_CEE_SAFE */
#ifndef _Out_capcount_x_
#define _Out_capcount_x_ __out_ecount_full
#endif /* _Out_capcount_x_ */
#ifndef _In_opt
#define _In_opt __in_opt
#endif /* _In_opt */
inline void fill_unchecked(
_Out_capcount_x_(_Last - _First) char *_First,
_In_opt char *_Last,
int _Val)
{ // copy char _Val through [_First, _Last)
std::memset(_First, _Val, _Last - _First);
}
inline void fill_unchecked(
_Out_capcount_x_(_Last - _First) signed char *_First,
_In_opt signed char *_Last,
int _Val)
{ // copy signed char _Val through [_First, _Last)
std::memset(_First, _Val, _Last - _First);
}
inline void fill_unchecked(
_Out_capcount_x_(_Last - _First) unsigned char *_First,
_In_opt unsigned char *_Last,
int _Val)
{ // copy unsigned char _Val through [_First, _Last)
std::memset(_First, _Val, _Last - _First);
}
#endif /* _M_CEE_SAFE */
template<class _FwdIt,
class _Ty> inline
void fill(_FwdIt _First, _FwdIt _Last, const _Ty% _Val)
{ // copy _Val through [_First, _Last)
_STLCLRDB_RANGE(_First, _Last);
cliext::fill_unchecked(_Unchecked(_First), _Unchecked(_Last), _Val);
}
// TEMPLATE FUNCTION fill_n
template<class _OutIt,
class _Diff,
class _Ty> inline
void fill_n_unchecked(_OutIt _First, _Diff _Count, const _Ty% _Val)
{ // copy _Val _Count times through [_First, ...)
for (; 0 < _Count; --_Count, ++_First)
*_First = _Val;
}
#ifdef _M_CEE_SAFE
#else /* _M_CEE_SAFE */
#ifndef _Out_opt_capcount_
#define _Out_opt_capcount_ __out_ecount_full_opt
#endif /* _Out_opt_capcount_ */
#ifndef _In_opt
#define _In_opt __in_opt
#endif /* _In_opt */
inline void fill_n_unchecked(
_Out_opt_capcount_(_Count) char *_First,
size_t _Count,
int _Val)
{ // copy char _Val _Count times through [_First, ...)
std::memset(_First, _Val, _Count);
}
inline void fill_n_unchecked(
_Out_opt_capcount_(_Count) signed char *_First,
size_t _Count,
int _Val)
{ // copy signed char _Val _Count times through [_First, ...)
std::memset(_First, _Val, _Count);
}
inline void fill_n_unchecked(
_Out_opt_capcount_(_Count) unsigned char *_First,
size_t _Count,
int _Val)
{ // copy unsigned char _Val _Count times through [_First, ...)
std::memset(_First, _Val, _Count);
}
#endif /* _M_CEE_SAFE */
template<class _OutIt,
class _Diff,
class _Ty> inline
void fill_n(_OutIt _First, _Diff _Count, const _Ty% _Val)
{ // copy _Val _Count times through [_First, ...)
#if _HAS_ITERATOR_DEBUGGING
if (0 < _Count)
_STLCLRDB_POINTER(_First);
#endif /* _HAS_ITERATOR_DEBUGGING */
cliext::fill_n_unchecked(_Unchecked(_First), _Count, _Val);
}
// TEMPLATE FUNCTION lexicographical_compare
template<class _InIt1,
class _InIt2> inline
bool lexicographical_compare_unchecked(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2, _InIt2 _Last2)
{ // order [_First1, _Last1) vs. [First2, Last2)
for (; _First1 != _Last1 && _First2 != _Last2; ++_First1, ++_First2)
if (_STLCLRDB_LT(*_First1, *_First2))
return (true);
else if (*_First2 < *_First1)
return (false);
return (_First1 == _Last1 && _First2 != _Last2);
}
#ifdef _M_CEE_SAFE
#else /* _M_CEE_SAFE */
inline bool lexicographical_compare_unchecked(
const unsigned char *_First1, const unsigned char *_Last1,
const unsigned char *_First2, const unsigned char *_Last2)
{ // order [_First1, _Last1) vs. [First2, Last2), for unsigned char
std::ptrdiff_t _Num1 = _Last1 - _First1;
std::ptrdiff_t _Num2 = _Last2 - _First2;
int _Ans = std::memcmp(_First1, _First2, _Num1 < _Num2 ? _Num1 : _Num2);
return (_Ans < 0 || _Ans == 0 && _Num1 < _Num2);
}
#if CHAR_MAX == UCHAR_MAX
inline bool lexicographical_compare_unchecked(
const char *_First1, const char *_Last1,
const char *_First2, const char *_Last2)
{ // order [_First1, _Last1) vs. [First2, Last2), for nonnegative char
std::ptrdiff_t _Num1 = _Last1 - _First1;
std::ptrdiff_t _Num2 = _Last2 - _First2;
int _Ans = std::memcmp(_First1, _First2, _Num1 < _Num2 ? _Num1 : _Num2);
return (_Ans < 0 || _Ans == 0 && _Num1 < _Num2);
}
#endif /* CHAR_MAX == UCHAR_MAX */
#endif /* _M_CEE_SAFE */
template<class _InIt1,
class _InIt2> inline
bool lexicographical_compare(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2, _InIt2 _Last2)
{ // order [_First1, _Last1) vs. [First2, Last2)
_STLCLRDB_RANGE(_First1, _Last1);
_STLCLRDB_RANGE(_First2, _Last2);
return (cliext::lexicographical_compare_unchecked(
_Unchecked(_First1), _Unchecked(_Last1),
_Unchecked(_First2), _Unchecked(_Last2)));
}
// TEMPLATE FUNCTION lexicographical_compare WITH PRED
template<class _InIt1,
class _InIt2,
class _Pr> inline
bool lexicographical_compare_unchecked(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2, _InIt2 _Last2, _Pr _Pred)
{ // order [_First1, _Last1) vs. [First2, Last2) using _Pred
for (; _First1 != _Last1 && _First2 != _Last2; ++_First1, ++_First2)
if (_STLCLRDB_LT_PRED(_Pred, *_First1, *_First2))
return (true);
else if (_Pred(*_First2, *_First1))
return (false);
return (_First1 == _Last1 && _First2 != _Last2);
}
template<class _InIt1,
class _InIt2,
class _Pr> inline
bool lexicographical_compare(_InIt1 _First1, _InIt1 _Last1,
_InIt2 _First2, _InIt2 _Last2, _Pr _Pred)
{ // order [_First1, _Last1) vs. [First2, Last2) using _Pred
_STLCLRDB_RANGE(_First1, _Last1);
_STLCLRDB_RANGE(_First2, _Last2);
_STLCLRDB_POINTER(_Pred);
return (cliext::lexicographical_compare_unchecked(
_Unchecked(_First1), _Unchecked(_Last1),
_Unchecked(_First2), _Unchecked(_Last2), _Pred));
}
// TEMPLATE FUNCTION max
template<class _Ty> inline
const _Ty (max)(const _Ty% _Left, const _Ty% _Right)
{ // return larger of _Left and _Right
return (_STLCLRDB_LT(_Left, _Right) ? _Right : _Left);
}
// TEMPLATE FUNCTION max WITH PRED
template<class _Ty,
class _Pr> inline
const _Ty (max)(const _Ty% _Left, const _Ty% _Right, _Pr _Pred)
{ // return larger of _Left and _Right using _Pred
return (_STLCLRDB_LT_PRED(_Pred, _Left, _Right) ? _Right : _Left);
}
// TEMPLATE FUNCTION min
template<class _Ty> inline
const _Ty (min)(const _Ty% _Left, const _Ty% _Right)
{ // return smaller of _Left and _Right
return (_STLCLRDB_LT(_Right, _Left) ? _Right : _Left);
}
// TEMPLATE FUNCTION min WITH PRED
template<class _Ty,
class _Pr> inline
const _Ty (min)(const _Ty% _Left, const _Ty% _Right, _Pr _Pred)
{ // return smaller of _Left and _Right using _Pred
return (_STLCLRDB_LT_PRED(_Pred, _Right, _Left) ? _Right : _Left);
}
} // namespace cliext
#endif /* _CLI_MEMORY_ */
/*
* Copyright (c) 2004-2007 by Dinkumware, Ltd. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V5.03:0009 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -