minmax
比較兩個輸入參數並作為一組傳回,從小排到大。
template<class Type>
pair<const Type&, const Type&>
minmax(
const Type& _Left,
const Type& _Right
);
template<class Type, class BinaryPredicate>
pair<const Type&, const Type&>
minmax(
const Type& _Left,
const Type& _Right,
BinaryPredicate _Comp
);
template<class Type>
pair<Type&, Type&>
minmax(
initializer_list<Type> _Ilist
);
template<class Type, class BinaryPredicate>
pair<Type&, Type&>
minmax(
initializer_list<Type> _Ilist,
BinaryPredicate _Comp
);
參數
_Left
要比較的第一個物件。_Right
要比較的第二個物件。_Comp
用於比較兩個物件的二進位述詞。_IList
包含要比較成員的 initializer_list 。
傳回值
傳回第一個是較少,第二個較大的一組物件。 在 initializer_list 情況下,這組會是清單中最少的物件和最大的物件。
備註
如果 _Right 小於 _Left,第一個樣板函式會傳回 pair<const Type&, const Type&>(_Right, _Left) 。 否則,它會傳回 pair<const Type&, const Type&>(_Left, _Right)。
當由述語 _Comp 比較時,第二個成員函式傳回第一個項目較少而第二個較大的配對。
其餘的樣板函式產生相同的行為,不過,它們以 _IList 取代 _Left 和 _Right 參數。
函式會恰好執行一次比較。
需求
標頭:<algorithm>
命名空間: std