home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / stlpt453.zip / STLport-4.5.3 / stlport / stl / wrappers / _hash_map.h < prev    next >
C/C++ Source or Header  |  2001-11-14  |  6KB  |  148 lines

  1. /*
  2.  * Copyright (c) 1999, 2000
  3.  * Boris Fomitchev
  4.  *
  5.  * This material is provided "as is", with absolutely no warranty expressed
  6.  * or implied. Any use is at your own risk.
  7.  *
  8.  * Permission to use or copy this software for any purpose is hereby granted 
  9.  * without fee, provided the above notices are retained on all copies.
  10.  * Permission to modify the code and to distribute modified code is granted,
  11.  * provided the above notices are retained, and a notice that the code was
  12.  * modified is included with the above copyright notice.
  13.  *
  14.  */
  15.  
  16. /* NOTE: This is an internal header file, included by other STL headers.
  17.  *   You should not attempt to use it directly.
  18.  */
  19.  
  20. #ifndef _STLP_INTERNAL_WRAP_HASH_MAP_H
  21. #define _STLP_INTERNAL_WRAP_HASH_MAP_H
  22.  
  23. #ifndef _STLP_INTERNAL_HASH_MAP_H
  24. # include <stl/_hash_map.h>
  25. #endif
  26.  
  27. # ifdef _STLP_USE_NAMESPACES
  28. namespace STLPORT { 
  29. # endif
  30.  
  31. // provide a "default" hash_map adaptor
  32. #  if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS)
  33. #   define __HM_TEMPLATE_HEADER  template <class _Key, class _Tp>
  34. #   define __HM_ARGUMENTS        _Key, _Tp
  35. #   define __HM_BASE_ARGUMENTS   _Key, _Tp, hash<_Key>, equal_to<_Key>, _STLP_DEFAULT_PAIR_ALLOCATOR(const _Key, _Tp)
  36. #  else
  37. #   define __HM_TEMPLATE_HEADER  template <class _Key, class _Tp, class _HashFcn, class _EqualKey >
  38. #   define __HM_ARGUMENTS        _Key, _Tp, _HashFcn, _EqualKey
  39. #   define __HM_BASE_ARGUMENTS   _Key, _Tp, _HashFcn, _EqualKey, _STLP_DEFAULT_PAIR_ALLOCATOR(const _Key, _Tp)
  40. #  endif
  41.  
  42.  
  43. # define __HM_SUPER  __hash_map< __HM_BASE_ARGUMENTS >
  44. # define __HMM_SUPER __hash_multimap< __HM_BASE_ARGUMENTS >
  45.  
  46. __HM_TEMPLATE_HEADER
  47. class hash_map : public __HM_SUPER
  48. {
  49.   typedef hash_map< __HM_ARGUMENTS > _Self;
  50. public:
  51.   typedef __HM_SUPER _Super;
  52.   __IMPORT_WITH_ITERATORS(_Super)
  53.   typedef typename _Super::key_type key_type;
  54.   typedef typename _Super::hasher hasher;
  55.   typedef typename _Super::key_equal key_equal;
  56.   typedef _Tp data_type;
  57.   hash_map() {}
  58.   hash_map(size_type __n) : __HM_SUPER(__n) {}
  59.   hash_map(size_type __n, const hasher& __hf) : __HM_SUPER(__n, __hf) {}
  60.   hash_map(size_type __n, const hasher& __hf, const key_equal& __eql): __HM_SUPER(__n, __hf, __eql) {}
  61.   hash_map(const value_type* __f, const value_type* __l) : __HM_SUPER(__f,__l) {}
  62.   hash_map(const value_type* __f, const value_type* __l, size_type __n): __HM_SUPER(__f,__l,__n) {}
  63.   hash_map(const value_type* __f, const value_type* __l, size_type __n, 
  64.            const hasher& __hf) : __HM_SUPER(__f,__l,__n,__hf) {}
  65.   hash_map(const value_type* __f, const value_type* __l, size_type __n,
  66.            const hasher& __hf, const key_equal& __eql) : __HM_SUPER(__f,__l,__n,__hf, __eql) {}
  67.   hash_map(const_iterator __f, const_iterator __l) : __HM_SUPER(__f,__l) { }
  68.   hash_map(const_iterator __f, const_iterator __l, size_type __n) : __HM_SUPER(__f,__l,__n) { }
  69.   hash_map(const_iterator __f, const_iterator __l, size_type __n,
  70.            const hasher& __hf) : __HM_SUPER(__f, __l, __n, __hf) { }
  71.   hash_map(const_iterator __f, const_iterator __l, size_type __n,
  72.            const hasher& __hf, const key_equal& __eql) : __HM_SUPER(__f, __l, __n, __hf, __eql) { }
  73. # if defined (_STLP_BASE_MATCH_BUG)
  74.   friend inline bool operator== _STLP_NULL_TMPL_ARGS (const _Self& __hm1, const _Self& __hm2);
  75. # endif
  76. };
  77.  
  78.  
  79. # if defined (_STLP_BASE_MATCH_BUG)
  80. __HM_TEMPLATE_HEADER
  81. inline bool operator==(const hash_map< __HM_ARGUMENTS >& __hm1, 
  82.                        const hash_map< __HM_ARGUMENTS >& __hm2)
  83. {
  84.     typedef __HM_SUPER _Super;
  85.     return (const _Super&)__hm1 == (const _Super&)__hm2; 
  86. }
  87. # endif
  88.  
  89. // provide a "default" hash_multimap adaptor
  90. __HM_TEMPLATE_HEADER
  91. class hash_multimap : public __HMM_SUPER
  92. {
  93.   typedef hash_multimap< __HM_ARGUMENTS > _Self;
  94. public:
  95.   typedef __HMM_SUPER _Super;
  96.   __IMPORT_WITH_ITERATORS(_Super)
  97.   typedef typename _Super::key_type key_type;
  98.   typedef typename _Super::hasher hasher;
  99.   typedef typename _Super::key_equal key_equal;
  100.   typedef _Tp data_type;
  101.   hash_multimap() {}
  102.   hash_multimap(size_type __n) : __HMM_SUPER(__n) {}
  103.   hash_multimap(size_type __n, const hasher& __hf) : __HMM_SUPER(__n, __hf) {}
  104.   hash_multimap(size_type __n, const hasher& __hf, const key_equal& __eql): __HMM_SUPER(__n, __hf, __eql) {}
  105.   hash_multimap(const value_type* __f, const value_type* __l) : __HMM_SUPER(__f,__l) {}
  106.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n): __HMM_SUPER(__f,__l,__n) {}
  107.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n, 
  108.            const hasher& __hf) : __HMM_SUPER(__f,__l,__n,__hf) {}
  109.   hash_multimap(const value_type* __f, const value_type* __l, size_type __n,
  110.            const hasher& __hf, const key_equal& __eql) : __HMM_SUPER(__f,__l,__n,__hf, __eql) {}
  111.  
  112.   hash_multimap(const_iterator __f, const_iterator __l) : __HMM_SUPER(__f,__l) { }
  113.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n) : __HMM_SUPER(__f,__l,__n) { }
  114.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
  115.            const hasher& __hf) : __HMM_SUPER(__f, __l, __n, __hf) { }
  116.   hash_multimap(const_iterator __f, const_iterator __l, size_type __n,
  117.            const hasher& __hf, const key_equal& __eql) : __HMM_SUPER(__f, __l, __n, __hf, __eql) { }
  118. # if defined (_STLP_BASE_MATCH_BUG)
  119.   friend inline bool operator== _STLP_NULL_TMPL_ARGS (const _Self& __hm1, const _Self& __hm2);
  120. # endif
  121. };
  122.  
  123. # if defined (_STLP_BASE_MATCH_BUG)
  124. __HM_TEMPLATE_HEADER
  125. inline bool operator==(const hash_multimap< __HM_ARGUMENTS >& __hm1, 
  126.                        const hash_multimap< __HM_ARGUMENTS >& __hm2)
  127. {
  128.     typedef __HMM_SUPER _Super;
  129.     return (const _Super&)__hm1 == (const _Super&)__hm2; 
  130. }
  131. # endif
  132.  
  133. # undef __HM_SUPER
  134. # undef __HMM_SUPER
  135. # undef __HM_TEMPLATE_HEADER
  136. # undef __HM_ARGUMENTS
  137. # undef __HM_BASE_ARGUMENTS
  138.  
  139. # ifdef _STLP_USE_NAMESPACES
  140. } /* namespace STLPORT */
  141. # endif
  142.  
  143. #endif /* _STLP_INTERNAL_HASH_SET_H */
  144.  
  145. // Local Variables:
  146. // mode:C++
  147. // End:
  148.