📄 ycpp_function.hpp
字号:
/*
* The young Library
* Copyright (c) 2005 by Yang Huan(杨桓)
* Permission to use, copy, modify, distribute and sell this software for any
* purpose is hereby granted without fee, provided that the above copyright
* notice appear in all copies and that both that copyright notice and this
* permission notice appear in supporting documentation.
* The author make no representations about the suitability of this software
* for any purpose. It is provided "as is" without express or implied warranty.
*/
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
#ifndef __MACRO_CPLUSPLUS_YOUNG_LIBRARY_FUNCTION_HEADER_FILE__
#define __MACRO_CPLUSPLUS_YOUNG_LIBRARY_FUNCTION_HEADER_FILE__
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
namespace youngcpp {
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
template< typename T >
inline int eq_adapter( const void* left, const void* right )
{
return *((const T*)left) == *((const T*)right) ? 0 : 1;
}
template< typename T, typename Equal >
inline int eq_adapter( const void* left, const void* right )
{
static Equal eq;
return eq( *((const T*)left), *((const T*)right) ) ? 0 : 1;
}
template< typename T >
inline int cmp_adapter( const void* left, const void* right )
{
int ret = 0;
if( *((const T*)left) < *((const T*)right) )
ret = -1;
else if( *((const T*)right) < *((const T*)left) )
ret = 1;
return ret;
}
template< typename T, typename Compare >
inline int cmp_adapter( const void* left, const void* right )
{
static Compare cmp;
int ret = 0;
if( cmp( *((const T*)left), *((const T*)right) ) )
ret = -1;
else if( cmp( *((const T*)right), *((const T*)left) ) )
ret = 1;
return ret;
}
template< typename T, typename Predicate >
inline int pred_adapter( const void* elmt, const void* )
{
static Predicate pred;
return pred( *((const T*)elmt) ) ? 0 : 1;
}
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
} //end namespace
#endif
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -