// TEMPLATE FUNCTION transform WITH UNARY OP
template<class _II, class _OI, class _Uop> inline
_OI transform(_II _F, _II _L, _OI _X, _Uop _U)
{for (; _F != _L; ++_F, ++_X)
*_X = _U(*_F);
return (_X); }
// TEMPLATE FUNCTION transform WITH BINARY OP
template<class _II1, class _II2, class _OI, class _Bop> inline
_OI transform(_II1 _F1, _II1 _L1, _II2 _F2, _OI _X, _Bop _B)
{for (; _F1 != _L1; ++_F1, ++_F2, ++_X)
*_X = _B(*_F1, *_F2);
return (_X); }
// TEMPLATE FUNCTION copy
template<class _II, class _OI> inline
_OI copy(_II _F, _II _L, _OI _X)
{for (; _F != _L; ++_X, ++_F)
*_X = *_F;
return (_X); }
// TEMPLATE FUNCTION copy_backward
template<class _BI1, class _BI2> inline
_BI2 copy_backward(_BI1 _F, _BI1 _L, _BI2 _X)
{while (_F != _L)
*--_X = *--_L;
return (_X); }
template<class _Ty> inline
void swap(_Ty& _X, _Ty& _Y)
{_Ty _Tmp = _X;
_X = _Y, _Y = _Tmp; }
// TEMPLATE FUNCTION iter_swap
template<class _FI1, class _FI2> inline
void iter_swap(_FI1 _X, _FI2 _Y)
{_Iter_swap(_X, _Y, _Val_type(_X)); }
template<class _FI1, class _FI2, class _Ty> inline
void _Iter_swap(_FI1 _X, _FI2 _Y, _Ty *)
{_Ty _Tmp = *_X;
*_X = *_Y, *_Y = _Tmp; }
// TEMPLATE FUNCTION swap_ranges
template<class _FI1, class _FI2> inline
_FI2 swap_ranges(_FI1 _F, _FI1 _L, _FI2 _X)
{for (; _F != _L; ++_F, ++_X)
iter_swap(_F, _X);
return (_X); }
// TEMPLATE FUNCTION replace
template<class _FI, class _Ty> inline
void replace(_FI _F, _FI _L, const _Ty& _Vo, const _Ty& _Vn)
{for (; _F != _L; ++_F)
if (*_F == _Vo)
*_F = _Vn; }
// TEMPLATE FUNCTION replace_if
template<class _FI, class _Pr, class _Ty> inline
void replace_if(_FI _F, _FI _L, _Pr _P, const _Ty& _V)
{for (; _F != _L; ++_F)
if (_P(*_F))
*_F = _V; }
// TEMPLATE FUNCTION generate
template<class _FI, class _Gen> inline
void generate(_FI _F, _FI _L, _Gen _G)
{for (; _F != _L; ++_F)
*_F = _G(); }
// TEMPLATE FUNCTION generate_n
template<class _OI, class _Pd, class _Gen> inline
void generate_n(_OI _F, _Pd _N, _Gen _G)
{for (; 0 < _N; --_N, ++_F)
*_F = _G(); }
// TEMPLATE FUNCTION remove
template<class _FI, class _Ty> inline
_FI remove(_FI _F, _FI _L, const _Ty& _V)
{_F = find(_F, _L, _V);
if (_F == _L)
return (_F);
else
{_FI _Fb = _F;
return (remove_copy(++_F, _L, _Fb, _V)); }}
// TEMPLATE FUNCTION remove_if
template<class _FI, class _Pr> inline
_FI remove_if(_FI _F, _FI _L, _Pr _P)
{_F = find_if(_F, _L, _P);
if (_F == _L)
return (_F);
else
{_FI _Fb = _F;
return (remove_copy_if(++_F, _L, _Fb, _P)); }}
// TEMPLATE FUNCTION remove_copy
template<class _II, class _OI, class _Ty> inline
_OI remove_copy(_II _F, _II _L, _OI _X, const _Ty& _V)
{for (; _F != _L; ++_F)
if (!(*_F == _V))
*_X++ = *_F;
return (_X); }
// TEMPLATE FUNCTION remove_copy_if
template<class _II, class _OI, class _Pr> inline
_OI remove_copy_if(_II _F, _II _L, _OI _X, _Pr _P)
{for (; _F != _L; ++_F)
if (!_P(*_F))
*_X++ = *_F;
return (_X); }
// TEMPLATE FUNCTION unique
template<class _FI> inline
_FI unique(_FI _F, _FI _L)
{_F = adjacent_find(_F, _L);
return (unique_copy(_F, _L, _F)); }
// TEMPLATE FUNCTION unique WITH PRED
template<class _FI, class _Pr> inline
_FI unique(_FI _F, _FI _L, _Pr _P)
{_F = adjacent_find(_F, _L, _P);
return (unique_copy(_F, _L, _F, _P)); }
// TEMPLATE FUNCTION unique_copy
template<class _II, class _OI> inline
_OI unique_copy(_II _F, _II _L, _OI _X)
{return (_F == _L ? _X :
_Unique_copy(_F, _L, _X, _Iter_cat(_F))); }
template<class _II, class _OI> inline
_OI _Unique_copy(_II _F, _II _L, _OI _X, input_iterator_tag)
{return (_Unique_copy(_F, _L, _X, _Val_type(_F))); }
template<class _II, class _OI, class _Ty> inline
_OI _Unique_copy(_II _F, _II _L, _OI _X, _Ty *)
{_Ty _V = *_F;
for (*_X++ = _V; ++_F != _L; )
if (!(_V == *_F))
_V = *_F, *_X++ = _V;
return (_X); }
template<class _FI, class _OI> inline
_OI _Unique_copy(_FI _F, _FI _L, _OI _X, forward_iterator_tag)
{_FI _Fb = _F;
for (*_X++ = *_Fb; ++_F != _L; )
if (!(*_Fb == *_F))
_Fb = _F, *_X++ = *_Fb;
return (_X); }
template<class _BI, class _OI> inline
_OI _Unique_copy(_BI _F, _BI _L, _OI _X,
bidirectional_iterator_tag)
{return (_Unique_copy(_F, _L, _X, forward_iterator_tag())); }
template<class _RI, class _OI> inline
_OI _Unique_copy(_RI _F, _RI _L, _OI _X,
random_access_iterator_tag)
{return (_Unique_copy(_F, _L, _X, forward_iterator_tag())); }
// TEMPLATE FUNCTION unique_copy WITH PRED
template<class _II, class _OI, class _Pr> inline
_OI unique_copy(_II _F, _II _L, _OI _X, _Pr _P)
{return (_F == _L ? _X :
_Unique_copy(_F, _L, _X, _P, _Iter_cat(_F))); }
template<class _II, class _OI, class _Pr> inline
_OI _Unique_copy(_II _F, _II _L, _OI _X, _Pr _P,
input_iterator_tag)
{return (_Unique_copy(_F, _L, _X, _P, _Val_type(_F))); }
template<class _II, class _OI, class _Ty, class _Pr> inline
_OI _Unique_copy(_II _F, _II _L, _OI _X, _Pr _P, _Ty *)
{_Ty _V = *_F;
for (*_X++ = _V; ++_F != _L; )
if (!_P(_V, *_F))
_V = *_F, *_X++ = _V;
return (_X); }
template<class _FI, class _OI, class _Pr> inline
_OI _Unique_copy(_FI _F, _FI _L, _OI _X, _Pr _P,
forward_iterator_tag)
{_FI _Fb = _F;
for (*_X++ = *_Fb; ++_F != _L; )
if (!_P(*_Fb, *_F))
_Fb = _F, *_X++ = *_Fb;
return (_X); }
template<class _BI, class _OI, class _Pr> inline
_OI _Unique_copy(_BI _F, _BI _L, _OI _X, _Pr _P,
bidirectional_iterator_tag)
{return (_Unique_copy(_F, _L, _X, _P,
forward_iterator_tag())); }
template<class _RI, class _OI, class _Pr> inline
_OI _Unique_copy(_RI _F, _RI _L, _OI _X, _Pr _P,
random_access_iterator_tag)
{return (_Unique_copy(_F, _L, _X, _P,
forward_iterator_tag())); }