⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 functional

📁 C语言库函数的原型,有用的拿去
💻
📖 第 1 页 / 共 2 页
字号:
//
// TEMPLATE CLASS not_equal_to
//
template<typename _Arg_t>
	ref class not_equal_to
	:	public _Binary_fun< ref_not_equal_to<_Arg_t> >
	{	// functor for not_equal_to
public:
	typedef not_equal_to _Mytype_t;

	not_equal_to()
		{	// default constructor
		}

	not_equal_to(not_equal_to%)
		{	// copy constructor
		}
	};

//
// TEMPLATE CLASS less
//
template<typename _Arg_t>
	ref class less
	:	public _Binary_fun< ref_less<_Arg_t> >
	{	// functor for less
public:
	typedef less _Mytype_t;

	less()
		{	// default constructor
		}

	less(less%)
		{	// copy constructor
		}
	};

//
// TEMPLATE CLASS greater_equal
//
template<typename _Arg_t>
	ref class greater_equal
	:	public _Binary_fun< ref_greater_equal<_Arg_t> >
	{	// functor for greater_equal
public:
	typedef greater_equal _Mytype_t;

	greater_equal()
		{	// default constructor
		}

	greater_equal(greater_equal%)
		{	// copy constructor
		}
	};

//
// TEMPLATE CLASS greater
//
template<typename _Arg_t>
	ref class greater
	:	public _Binary_fun< ref_greater<_Arg_t> >
	{	// functor for greater
public:
	typedef greater _Mytype_t;

	greater()
		{	// default constructor
		}

	greater(greater%)
		{	// copy constructor
		}
	};

//
// TEMPLATE CLASS less_equal
//
template<typename _Arg_t>
	ref class less_equal
	:	public _Binary_fun< ref_less_equal<_Arg_t> >
	{	// functor for less_equal
public:
	typedef less_equal _Mytype_t;

	less_equal()
		{	// default constructor
		}

	less_equal(less_equal%)
		{	// copy constructor
		}
	};

//
// TEMPLATE CLASS logical_and
//
template<typename _Arg_t>
	ref class logical_and
	:	public _Binary_fun< ref_logical_and<_Arg_t> >
	{	// functor for logical_and
public:
	typedef logical_and _Mytype_t;

	logical_and()
		{	// default constructor
		}

	logical_and(logical_and%)
		{	// copy constructor
		}
	};

//
// TEMPLATE CLASS logical_or
//
template<typename _Arg_t>
	ref class logical_or
	:	public _Binary_fun< ref_logical_or<_Arg_t> >
	{	// functor for logical_or
public:
	typedef logical_or _Mytype_t;

	logical_or()
		{	// default constructor
		}

	logical_or(logical_or%)
		{	// copy constructor
		}
	};

//
// TEMPLATE REF CLASS ref_unary_negate
//
template<typename _Arg_t,
	typename _Result_t>
	ref class ref_unary_negate
	{	// generic functor for unary_negate
public:
	typedef _Arg_t argument_type;
	typedef _Result_t result_type;
	typedef _STLCLR UnaryDelegate<argument_type, result_type>
		stored_delegate_type;

	ref_unary_negate(stored_delegate_type^ _Function)
		:	stored_delegate(_Function)
		{	// construct stored delegate from function
		}

	bool function(argument_type _Left)
		{	// do the operation
		return (!stored_delegate(_Left));
		}

_STLCLR_FIELD_ACCESS:
	stored_delegate_type^ stored_delegate;	// the stored delegate
	};

//
// TEMPLATE CLASS unary_negate
//
template<typename _Fun_t>
	ref class unary_negate
	{	// functor for unary_negate
public:
	typedef unary_negate _Mytype_t;
	typedef _Fun_t stored_function_type;
	typedef typename stored_function_type::argument_type argument_type;
	typedef bool result_type;
	typedef ref_unary_negate<argument_type,
		typename stored_function_type::result_type> ref_type;
	typedef _STLCLR UnaryDelegate<argument_type, result_type>
		delegate_type;

	explicit unary_negate(stored_function_type% _Func)
		:	op(_Func)
		{	// construct from functor
		}

	unary_negate(unary_negate%)
		{	// copy constructor
		}

	result_type operator()(argument_type _Left)
		{	// apply functor to operand
		return (!op(_Left));
		}

	operator delegate_type^()
		{	// convert function to delegate
		return (gcnew delegate_type(gcnew ref_type(op),
			%ref_type::function));
		}

_STLCLR_FIELD_ACCESS:
	stored_function_type op;	// the stored functor to apply
	};

//
// TEMPLATE FUNCTION not1
//
template<typename _Fun_t> inline
	unary_negate<_Fun_t> not1(_Fun_t% _Func)
	{	// return a unary_negate functor adapter
	return (unary_negate<_Fun_t>(_Func));
	}

//
// TEMPLATE REF CLASS ref_binary_negate
//
template<typename _Arg1_t,
	typename _Arg2_t,
	typename _Result_t>
	ref class ref_binary_negate
	{	// generic functor for binary_negate
public:
	typedef _Arg1_t first_argument_type;
	typedef _Arg2_t second_argument_type;
	typedef _Result_t result_type;
	typedef _STLCLR BinaryDelegate<
		first_argument_type, second_argument_type, result_type>
		stored_delegate_type;

	ref_binary_negate(stored_delegate_type^ _Function)
		:	stored_delegate(_Function)
		{	// construct stored delegate from function
		}

	bool function(first_argument_type _Left,
		second_argument_type _Right)
		{	// do the operation
		return (!stored_delegate(_Left, _Right));
		}

_STLCLR_FIELD_ACCESS:
	stored_delegate_type^ stored_delegate;	// the stored delegate
	};

//
// TEMPLATE CLASS binary_negate
//
template<typename _Fun_t>
	ref class binary_negate
	{	// functor for binary_negate
public:
	typedef binary_negate _Mytype_t;
	typedef _Fun_t stored_function_type;
	typedef typename stored_function_type::first_argument_type
		first_argument_type;
	typedef typename stored_function_type::second_argument_type
		second_argument_type;
	typedef bool result_type;
	typedef ref_binary_negate<first_argument_type, second_argument_type,
		typename stored_function_type::result_type> ref_type;
	typedef _STLCLR BinaryDelegate<
		first_argument_type, second_argument_type, result_type>
		delegate_type;

	explicit binary_negate(stored_function_type% _Func)
		:	op(_Func)
		{	// construct from functor
		}

	binary_negate(binary_negate%)
		{	// copy constructor
		}

	result_type operator()(first_argument_type _Left,
		second_argument_type _Right)
		{	// apply functor to operands
		return (!op(_Left, _Right));
		}

	operator delegate_type^()
		{	// convert function to delegate
		return (gcnew delegate_type(gcnew ref_type(op),
			%ref_type::function));
		}

_STLCLR_FIELD_ACCESS:
	stored_function_type op;	// the stored functor to apply
	};

//
// TEMPLATE FUNCTION not2
//
template<typename _Fun_t> inline
	binary_negate<_Fun_t> not2(_Fun_t% _Func)
	{	// return a binary_negate functor adapter
	return (binary_negate<_Fun_t>(_Func));
	}

//
// TEMPLATE REF CLASS ref_binder1st
//
template<typename _Arg1_t,
	typename _Arg2_t,
	typename _Result_t>
	ref class ref_binder1st
	{	// generic functor for binder1st
public:
	typedef _Arg1_t first_argument_type;
	typedef _Arg2_t second_argument_type;
	typedef _Result_t result_type;
	typedef _STLCLR BinaryDelegate<
		first_argument_type, second_argument_type, result_type>
		stored_delegate_type;

	ref_binder1st(stored_delegate_type^ _Function, first_argument_type _Left)
		:	stored_delegate(_Function), value(_Left)
		{	// construct with delegate object and first argument
		}

	result_type function(second_argument_type _Right)
		{	// do the operation
		return (stored_delegate(value, _Right));
		}

_STLCLR_FIELD_ACCESS:
	stored_delegate_type^ stored_delegate;	// the stored delegate
	first_argument_type value;	// the stored first argument
	};

//
// TEMPLATE CLASS binder1st
//
template<typename _Fun_t>
	ref class binder1st
	{	// functor for binder1st
public:
	typedef binder1st _Mytype_t;
	typedef _Fun_t stored_function_type;
	typedef typename stored_function_type::first_argument_type
		first_argument_type;
	typedef typename stored_function_type::second_argument_type
		second_argument_type;
	typedef typename stored_function_type::result_type result_type;
	typedef ref_binder1st<first_argument_type, second_argument_type,
		result_type> ref_type;
	typedef _STLCLR UnaryDelegate<second_argument_type, result_type>
		delegate_type;

	binder1st(stored_function_type% _Func,
		first_argument_type _Left)
		:	op(_Func), value(_Left)
		{	// construct from functor
		}

	binder1st(binder1st% _Right)
		: op(_Right.op), value(_Right.value)
		{	// copy constructor
		}

	result_type operator()(second_argument_type _Right)
		{	// apply functor to operands
		return (op(value, _Right));
		}

	operator delegate_type^()
		{	// convert function to delegate
		return (gcnew delegate_type(
			gcnew ref_type(op, value),
			&ref_type::function));
		}

_STLCLR_FIELD_ACCESS:
	stored_function_type op;	// the stored functor to apply
	first_argument_type value;	// the stored left argument
	};

//
// TEMPLATE FUNCTION bind1st
//
template<typename _Fun_t,
	typename _Arg_t> inline
	binder1st<_Fun_t> bind1st(_Fun_t% _Func, _Arg_t _Left)
	{	// return a binder1st functor adapter
	typename _Fun_t::first_argument_type _Val = _Left;

	return (binder1st<_Fun_t>(_Func, _Val));
	}

//
// TEMPLATE REF CLASS ref_binder2nd
//
template<typename _Arg1_t,
	typename _Arg2_t,
	typename _Result_t>
	ref class ref_binder2nd
	{	// generic functor for binder2nd
public:
	typedef _Arg1_t first_argument_type;
	typedef _Arg2_t second_argument_type;
	typedef _Result_t result_type;
	typedef _STLCLR BinaryDelegate<
		first_argument_type, second_argument_type, result_type>
		stored_delegate_type;

	ref_binder2nd(stored_delegate_type^ _Function,
		second_argument_type _Right)
		:	stored_delegate(_Function), value(_Right)
		{	// construct with delegate object and second argument
		}

	result_type function(first_argument_type _Left)
		{	// do the operation
		return (stored_delegate(_Left, value));
		}

_STLCLR_FIELD_ACCESS:
	stored_delegate_type^ stored_delegate;	// the stored delegate
	second_argument_type value;	// the stored second argument
	};

//
// TEMPLATE CLASS binder2nd
//
template<typename _Fun_t>
	ref class binder2nd
	{	// functor for binder2nd
public:
	typedef binder2nd _Mytype_t;
	typedef _Fun_t stored_function_type;
	typedef typename stored_function_type::first_argument_type
		first_argument_type;
	typedef typename stored_function_type::second_argument_type
		second_argument_type;
	typedef typename stored_function_type::result_type result_type;
	typedef ref_binder2nd<first_argument_type, second_argument_type,
		result_type> ref_type;
	typedef _STLCLR UnaryDelegate<first_argument_type, result_type>
		delegate_type;

	binder2nd(stored_function_type% _Func,
		second_argument_type _Right)
		:	op(_Func), value(_Right)
		{	// construct from functor
		}

	binder2nd(binder2nd% _Right)
		: op(_Right.op), value(_Right.value)
		{	// copy constructor
		}

	result_type operator()(second_argument_type _Left)
		{	// apply functor to operands
		return (op(_Left, value));
		}

	operator delegate_type^()
		{	// convert function to delegate
		return (gcnew delegate_type(
			gcnew ref_type(op, value),
			&ref_type::function));
		}

_STLCLR_FIELD_ACCESS:
	stored_function_type op;	// the stored functor to apply
	second_argument_type value;	// the stored right argument
	};

//
// TEMPLATE FUNCTION bind2nd
//
template<typename _Fun_t,
	typename _Arg_t> inline
	binder2nd<_Fun_t> bind2nd(_Fun_t% _Func, _Arg_t _Right)
	{	// return a binder2nd functor adapter
	typename _Fun_t::second_argument_type _Val = _Right;

	return (binder2nd<_Fun_t>(_Func, _Val));
	}

//
// TEMPLATE CLASS comparer_less
//
template<typename _Arg_t,
	typename _Mycomp_t>
	ref class comparer_less
	{	// functor for comparer_less
public:
	typedef comparer_less<_Arg_t, _Mycomp_t> _Mytype_t;
	typedef _Arg_t argument_type;
	typedef _STLCLR BinaryDelegate<
		argument_type, argument_type, bool>
		delegate_type;

	comparer_less(_Mycomp_t^ _Comp)
		:	_Mycomp(_Comp)
		{	// construct from comparer
		}

	comparer_less(comparer_less% _Right)
		:	_Mycomp(_Right._Mycomp)
		{	// construct by copying comparer
		}

	bool operator()(argument_type _Left, argument_type _Right)
		{	// do the operation
		return (function(_Left, _Right));
		}

	operator delegate_type^()
		{	// convert function to delegate
		return (gcnew delegate_type(%function));
		}

	static bool function(argument_type _Left, argument_type _Right)
		{	// do the operation
		return (_Mycomp->Compare(_Left, _Right) < 0);
		}

_STLCLR_FIELD_ACCESS:
	_Mycomp_t^ _Mycomp;	// the stored IComparer object
	};

//
// TEMPLATE FUNCTION make_comparer_less
//
template<typename _Arg_t> inline
	comparer_less<_Arg_t,
		System::Collections::Generic::IComparer<_Arg_t> >^
	make_comparer_less(
		System::Collections::Generic::IComparer<_Arg_t>^ _Comp)
	{	// make comparer less from IComparer<T>
	typedef System::Collections::Generic::IComparer<_Arg_t> _Mycomp_t;

	return (gcnew comparer_less<_Arg_t, _Mycomp_t>(_Comp));
	}

inline comparer_less<System::Object^, System::Collections::IComparer>^
	make_comparer_less(System::Collections::IComparer^ _Comp)
	{	// make comparer less from IComparer
	typedef System::Collections::IComparer _Mycomp_t;

	return (gcnew comparer_less<System::Object^, _Mycomp_t>(_Comp));
	}
}	// namespace cliext
#endif // _CLI_FUNCTIONAL_

/*
 * 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 + -