S T L ¹þÏ£Ëã·¨ÏêϸÆÊÎö 1
ÓÉÓÚÌ«³¤£¬ËùÒÔÖ»ÆÊÎöÁËÒ»°ë£¬¶øÇÒÌû×ÓÒ²²»ÔÊÐíÌù³¬¹ý10000¸ö×Ö·û£¬ËùÒÔÖ»ÓзֶÎÌù¡£stl_hash_map.h
DarkSpy 2002/5/15
[code]
/*
* Copyright (c) 1996
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation 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. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation 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. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#ifndef __SGI_STL_INTERNAL_HASH_MAP_H
#define __SGI_STL_INTERNAL_HASH_MAP_H
#include <concept_checks.h>
__STL_BEGIN_NAMESPACE
#if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
#pragma set woff 1174
#pragma set woff 1375
#endif
// Forward declaration of equality operator; needed for friend declaration.
template <class _Key, class _Tp,
class _HashFcn __STL_DEPENDENT_DEFAULT_TMPL(hash<_Key>),
class _EqualKey __STL_DEPENDENT_DEFAULT_TMPL(equal_to<_Key>),
class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
class hash_map;
//__STL_DEPENDENT_DEFAULT_TMPL ÊÇÒ»¸öºê£¬Òâ˼ÊÇÈç¹û±àÒëÆ÷²»Ö§³ÖĬÈÏÄ£°å²ÎÊý£¬ÔòʹÓÃÉÏÒ»¼¶Ä£°å²ÎÊý
//__STL_DEFAULT_ALLOCATOR µÈÓÚ allocator <T>
//equal_to µÄ¶¨Òå¿ÉÒÔÔÚ stl_function.h ÕÒµ½
/*template <class _Tp>
struct equal_to : public binary_function<_Tp,_Tp,bool>
{
bool operator()(const _Tp& __x, const _Tp& __y) const { return __x == __y; }
//ÖØÔØ (), ´«»Ø _Tp ÀàÐÍÏàµÈÐÅÏ¢£¬Ï൱ÓÚÕâÑùµÄ¸üÖ±¹ÛµÄ´úÂë:
// bool operator==(const _Tp &x, const _Tp &y) const
{ return x == y; }
};
Õâ¶Î¶¨ÒåÏ൱ÓÚ:
template <class _Key, class _Tp,
class _HashFcn = hash<_Key>,
class _EqualKey = equal_to<_Key>,
class _Alloc = allocator<_Tp> >
class hash_map;
ǰÖÃÀàÐͶ¨Òå
*/
template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc>
inline bool operator==(const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&,
const hash_map<_Key, _Tp, _HashFn, _EqKey, _Alloc>&);
template <class _Key, class _Tp, class _HashFcn, class _EqualKey,
class _Alloc>
class hash_map
{
// requirements:
__STL_CLASS_REQUIRES(_Key, _Assignable);
__STL_CLASS_REQUIRES(_Tp, _Assignable);
__STL_CLASS_UNARY_FUNCTION_CHECK(_HashFcn, size_t, _Key);
__STL_CLASS_BINARY_FUNCTION_CHECK(_EqualKey, bool, _Key, _Key);
/*
__STL_CLASS_REQUIRES ÊÇÒ»¸öºê£¬½«µÚÒ»¾äÕ¹¿ªÖ®ºóÏ൱ÓÚ
typedef void (* __func_Key_Assignable) ( _Key );
template <__func_Key_Assignable _Tp1>
struct __dummy_struct__Key_Assignable { };
static __dummy_struct__Key_Assignable< _Assignable_specification <Assignable>::_Key_requirement_violation> __dummy_ptr__Key_Assignable
__STL_CLASS_UNARY_FUNCTION_CHECK ÊÇÒ»¸öºê£¬½«µÚÈý¾äÕ¹¿ªÖ®ºóÏ൱ÓÚ
typedef size_t (* __f__HashFcn_size_t_Key_unary_check)( _HashFcn&, const _Key& );
template <__f__HashFcn_size_t_Key_unary_check _Tp1>
struct __dummy_struct__HashFcn_size_t_Key_unary_check { };
static __dummy_struct__HashFcn_size_t_Key_unary_check< _STL_UNARY_FUNCTION_ERROR< _HashFcn, size_t, _Key>::__unary_function_requirement_violation>
__dummy_ptr__HashFcn_size_t_Key_unary_check
__STL_CLASS_BINARY_FUNCTION_CHECK ÊÇÒ»¸öºê£¬½«µÚËľäÕ¹¿ªºóÏ൱ÓÚ
typedef bool (* __f__EqualKey_bool_Key_Key_binary_check)( _EqualKey&, const _Key&, const _Key& );
template <__f__EqualKey_bool_Key_Key_binary_check _Tp1>
struct __dummy_struct__EqualKey_bool_Key_Key_binary_check { };
static __dummy_struct__EqualKey_bool_Key_Key_binary_check< _STL_BINARY_FUNCTION_ERROR<_EqualKey, bool, _Key, _Key>::__binary_function_requirement_violation>
__dummy_ptr__EqualKey_bool_Key_Key_binary_check
Óúܼò½àµÄÊÖ·¨¶¨ÒåÁËÄ£°åÄÚÄ£°å£¬ÊDz»ÊǷdz£Æ¯ÁÁÄØ£¿
*/
.............ÂÔ£¬´ýÏ»طֽ⡣:-)
[/code] ½ÓÏÂÀ´£¬Èç¹ûÒª¿´ÏÂÃæµÄ´úÂ룬±ØÐëÏÈÖªµÀ pair Ä£°åÀàµÄϸ½Ú£¬ÏÂÃæÊÇ DarkSpy ¶ÔÓÚ pair Ä£°åÀàµÄÆÊÎö
DarkSpy 2002/5/16
[code]
/*
*
* Copyright (c) 1994
* Hewlett-Packard Company
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation 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. Hewlett-Packard Company makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*
*
* Copyright (c) 1996,1997
* Silicon Graphics Computer Systems, Inc.
*
* Permission to use, copy, modify, distribute and sell this software
* and its documentation 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. Silicon Graphics makes no
* representations about the suitability of this software for any
* purpose. It is provided "as is" without express or implied warranty.
*/
/* NOTE: This is an internal header file, included by other STL headers.
* You should not attempt to use it directly.
*/
#ifndef __SGI_STL_INTERNAL_PAIR_H
#define __SGI_STL_INTERNAL_PAIR_H
__STL_BEGIN_NAMESPACE
template <class _T1, class _T2>
struct pair {
typedef _T1 first_type;
typedef _T2 second_type;
_T1 first;
_T2 second;
pair() : first(_T1()), second(_T2()) {} //½«first ºÍ second ¶ÔÏó¹¹ÔìÆðÀ´²¢³õʼ»¯
pair(const _T1& __a, const _T2& __b) : first(__a), second(__b) {}
//¿½±´¹¹Ô죬Èç¹ûÕâÑùдpair<T1_Type, T2_Type> pair_object(T1, T2); Ôò±£Ö¤¹¹Ôì
#ifdef __STL_MEMBER_TEMPLATES //Èç¹û±àÒëÆ÷Ö§³Ö³ÉÔ±ÄÚÄ£°å£¬Ôò
template <class _U1, class _U2>
pair(const pair<_U1, _U2>& __p) : first(__p.first), second(__p.second) {}
//¿½±´¹¹Ô죬³ÉÔ±ÄÚÄ£°å£¬±£Ö¤ first ºÍ second Äܸù¾Ý pair ¹¹ÔìÆðÀ´.
#endif
};
template <class _T1, class _T2>
inline bool operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{
return __x.first == __y.first && __x.second == __y.second;
} //ÖØÔØ==£¬·µ»Ø x ²ÎÊýºÍ y ²ÎÊýµÄÁ½¸öÄ£°å²ÎÊýÏàµÈ.
template <class _T1, class _T2>
inline bool operator<(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
{
return __x.first < __y.first ||
(!(__y.first < __x.first) && __x.second < __y.second);
} //ÖØÔØ <£¬·µ»Ø x ²ÎÊýºÍ y ²ÎÊýµÄÁ½¸öÄ£°å²ÎÊýСÓÚÅжÏ
#ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
//Èç¹û±àÒëÆ÷Ö§³Ö³ÉÔ±ÄÚÄ£°å¾Ö²¿ÌØÀý»¯£¨Æ«ÌØ»¯£©
template <class _T1, class _T2>
inline bool operator!=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
return !(__x == __y);
} //ÖØÔØ!=£¬·µ»Ø _x ºÍ _y ²ÎÊý != ÅжÏ
template <class _T1, class _T2>
inline bool operator>(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
return __y < __x;
} //ÖØÔØ >£¬·µ»Ø _x > _y ÅжÏ
template <class _T1, class _T2>
inline bool operator<=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
return !(__y < __x);
} //ÖØÔØ <=£¬·µ»Ø _x < _y ÅжÏ
template <class _T1, class _T2>
inline bool operator>=(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y) {
return !(__x < __y);
} //ÖØÔØ >=£¬·µ»Ø _x > _y ÅжÏ
#endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
template <class _T1, class _T2>
inline pair<_T1, _T2> make_pair(const _T1& __x, const _T2& __y)
{
return pair<_T1, _T2>(__x, __y);
} //make_pairÏ൱ÓÚÀûÓà pair µÄ¿½±´¹¹Ô죬¹¹Ôì²¢³õʼ»¯³ö _x ºÍ _y
//Ï൱ÓÚÕâÑùд pair<T1_Type, T2_Type> p_object(T1, T2);
//¶øÓÃmake_pair¾Í¿ÉÒÔÖ±½ÓÕâÑùд make_pair(T1, T2);
__STL_END_NAMESPACE
#endif /* __SGI_STL_INTERNAL_PAIR_H */
// Local Variables:
// mode:C++
// End:
[/code]
Ò³:
[1]