1 _map.h |
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_MAP_H |
|
21 #define _STLP_INTERNAL_WRAP_MAP_H |
|
22 |
|
23 #ifndef _STLP_INTERNAL_MAP_H |
|
24 # include <stl/_map.h> |
|
25 #endif |
|
26 |
|
27 # ifdef _STLP_USE_NAMESPACES |
|
28 namespace STLPORT { |
|
29 # endif |
|
30 |
|
31 # if defined (_STLP_MINIMUM_DEFAULT_TEMPLATE_PARAMS) |
|
32 # define __MAP_TEMPLATE_HEADER template <class _Key, class _Tp> |
|
33 # define __MAP_ARGUMENTS _Key, _Tp |
|
34 # define __MMAP_TEMPLATE_HEADER template <class _Key, class _Tp> |
|
35 # define __MMAP_ARGUMENTS _Key, _Tp |
|
36 # define _Compare less<_Key> |
|
37 # else |
|
38 # define __MAP_TEMPLATE_HEADER template <class _Key, class _Tp, class _Compare > |
|
39 # define __MAP_ARGUMENTS _Key, _Tp, _Compare |
|
40 # define __MMAP_TEMPLATE_HEADER template <class _Key, class _Tp, class _Compare > |
|
41 # define __MMAP_ARGUMENTS _Key, _Tp, _Compare |
|
42 # endif |
|
43 |
|
44 |
|
45 # define __MAP_SUPER __map< _Key, _Tp, _Compare, _STLP_DEFAULT_PAIR_ALLOCATOR(const _Key, _Tp) > |
|
46 # define __MMAP_SUPER __multimap< _Key, _Tp, _Compare, _STLP_DEFAULT_PAIR_ALLOCATOR(const _Key, _Tp) > |
|
47 |
|
48 // provide a "default" map adaptor |
|
49 __MAP_TEMPLATE_HEADER |
|
50 class map : public __MAP_SUPER |
|
51 { |
|
52 typedef map< __MAP_ARGUMENTS > _Self; |
|
53 public: |
|
54 typedef __MAP_SUPER _Super; |
|
55 __IMPORT_WITH_REVERSE_ITERATORS(_Super) |
|
56 __IMPORT_SUPER_COPY_ASSIGNMENT(map, _Self, __MAP_SUPER) |
|
57 map() : __MAP_SUPER(_Compare()) {} |
|
58 explicit map(const _Compare& __comp) : __MAP_SUPER(__comp) {} |
|
59 map(const typename _Super::value_type* __first, |
|
60 const typename _Super::value_type* __last) : |
|
61 __MAP_SUPER(__first, __last, _Compare()) { } |
|
62 map(const typename _Super::value_type* __first, |
|
63 const typename _Super::value_type* __last, |
|
64 const _Compare& __comp) : __MAP_SUPER(__first, __last, __comp) { } |
|
65 map(typename _Super::const_iterator __first, |
|
66 typename _Super::const_iterator __last) : |
|
67 __MAP_SUPER(__first, __last, _Compare()) { } |
|
68 map(typename _Super::const_iterator __first, |
|
69 typename _Super::const_iterator __last, |
|
70 const _Compare& __comp) : __MAP_SUPER(__first, __last, __comp) { } |
|
71 }; |
|
72 |
|
73 # if defined (_STLP_BASE_MATCH_BUG) |
|
74 __MAP_TEMPLATE_HEADER |
|
75 inline bool operator==(const map< __MAP_ARGUMENTS >& __x, |
|
76 const map< __MAP_ARGUMENTS >& __y) { |
|
77 typedef __MAP_SUPER _Super; |
|
78 return operator==((const _Super&)__x,(const _Super&)__y); |
|
79 } |
|
80 |
|
81 __MAP_TEMPLATE_HEADER |
|
82 inline bool operator<(const map< __MAP_ARGUMENTS >& __x, |
|
83 const map< __MAP_ARGUMENTS >& __y) { |
|
84 typedef __MAP_SUPER _Super; |
|
85 return operator < ((const _Super&)__x,(const _Super&)__y); |
|
86 } |
|
87 # endif /* _STLP_BASE_MATCH_BUG */ |
|
88 |
|
89 |
|
90 // provide a "default" multimap adaptor |
|
91 __MMAP_TEMPLATE_HEADER |
|
92 class multimap : public __MMAP_SUPER |
|
93 { |
|
94 typedef multimap< __MMAP_ARGUMENTS > _Self; |
|
95 public: |
|
96 typedef __MMAP_SUPER _Super; |
|
97 __IMPORT_WITH_REVERSE_ITERATORS(_Super) |
|
98 // copy & assignment from super |
|
99 __IMPORT_SUPER_COPY_ASSIGNMENT(multimap, _Self, __MMAP_SUPER) |
|
100 multimap() : __MMAP_SUPER(_Compare()) {} |
|
101 explicit multimap(const _Compare& __comp) : __MMAP_SUPER(__comp) {} |
|
102 multimap(const typename _Super::value_type* __first, |
|
103 const typename _Super::value_type* __last) : |
|
104 __MMAP_SUPER(__first, __last, _Compare()) { } |
|
105 multimap(const typename _Super::value_type* __first, |
|
106 const typename _Super::value_type* __last, |
|
107 const _Compare& __comp) : __MMAP_SUPER(__first, __last, __comp) { } |
|
108 multimap(typename _Super::const_iterator __first, |
|
109 typename _Super::const_iterator __last) : |
|
110 __MMAP_SUPER(__first, __last, _Compare()) { } |
|
111 multimap(typename _Super::const_iterator __first, |
|
112 typename _Super::const_iterator __last, |
|
113 const _Compare& __comp) : __MMAP_SUPER(__first, __last, __comp) { } |
|
114 }; |
|
115 |
|
116 # if defined (_STLP_BASE_MATCH_BUG) |
|
117 __MMAP_TEMPLATE_HEADER |
|
118 inline bool operator==(const multimap< __MMAP_ARGUMENTS >& __x, |
|
119 const multimap< __MMAP_ARGUMENTS >& __y) { |
|
120 typedef __MMAP_SUPER _Super; |
|
121 return (const _Super&)__x == (const _Super&)__y; |
|
122 } |
|
123 |
|
124 __MMAP_TEMPLATE_HEADER |
|
125 inline bool operator<(const multimap< __MMAP_ARGUMENTS >& __x, |
|
126 const multimap< __MMAP_ARGUMENTS >& __y) { |
|
127 typedef __MMAP_SUPER _Super; |
|
128 return (const _Super&)__x < (const _Super&)__y; |
|
129 } |
|
130 # endif |
|
131 |
|
132 # undef __MMAP_TEMPLATE_HEADER |
|
133 # undef __MMAP_ARGUMENTS |
|
134 # undef __MMAP_SUPER |
|
135 |
|
136 # undef __MAP_TEMPLATE_HEADER |
|
137 # undef __MAP_ARGUMENTS |
|
138 # undef __MAP_SUPER |
|
139 |
|
140 # undef _Compare |
|
141 |
|
142 # ifdef _STLP_USE_NAMESPACES |
|
143 } /* namespace STLPORT */ |
|
144 # endif |
|
145 |
|
146 #endif /* _STLP_INTERNAL_WRAP_MAP_H */ |
|
147 |
|
148 // Local Variables: |
|
149 // mode:C++ |
|
150 // End: |