Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
4680 right-hear 1
/*
2
 *
3
 * Copyright (c) 1994
4
 * Hewlett-Packard Company
5
 *
6
 * Permission to use, copy, modify, distribute and sell this software
7
 * and its documentation for any purpose is hereby granted without fee,
8
 * provided that the above copyright notice appear in all copies and
9
 * that both that copyright notice and this permission notice appear
10
 * in supporting documentation.  Hewlett-Packard Company makes no
11
 * representations about the suitability of this software for any
12
 * purpose.  It is provided "as is" without express or implied warranty.
13
 *
14
 *
15
 * Copyright (c) 1996,1997
16
 * Silicon Graphics Computer Systems, Inc.
17
 *
18
 * Permission to use, copy, modify, distribute and sell this software
19
 * and its documentation for any purpose is hereby granted without fee,
20
 * provided that the above copyright notice appear in all copies and
21
 * that both that copyright notice and this permission notice appear
22
 * in supporting documentation.  Silicon Graphics makes no
23
 * representations about the suitability of this software for any
24
 * purpose.  It is provided "as is" without express or implied warranty.
25
 */
26
 
27
/* NOTE: This is an internal header file, included by other STL headers.
28
 *   You should not attempt to use it directly.
29
 */
30
 
31
#ifndef __SGI_STL_INTERNAL_MULTIMAP_H
32
#define __SGI_STL_INTERNAL_MULTIMAP_H
33
 
34
#include 
35
 
36
namespace std
37
{
38
 
39
// Forward declaration of operators < and ==, needed for friend declaration.
40
 
41
template 
42
          class _Compare = less<_Key>,
43
          class _Alloc = allocator > >
44
class multimap;
45
 
46
template 
47
inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
48
                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
49
 
50
template 
51
inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
52
                      const multimap<_Key,_Tp,_Compare,_Alloc>& __y);
53
 
54
template 
55
class multimap
56
{
57
  // concept requirements
58
  __glibcpp_class_requires(_Tp, _SGIAssignableConcept);
59
  __glibcpp_class_requires4(_Compare, bool, _Key, _Key, _BinaryFunctionConcept);
60
 
61
public:
62
 
63
// typedefs:
64
 
65
  typedef _Key                  key_type;
66
  typedef _Tp                   data_type;
67
  typedef _Tp                   mapped_type;
68
  typedef pair value_type;
69
  typedef _Compare              key_compare;
70
 
71
  class value_compare : public binary_function {
72
  friend class multimap<_Key,_Tp,_Compare,_Alloc>;
73
  protected:
74
    _Compare comp;
75
    value_compare(_Compare __c) : comp(__c) {}
76
  public:
77
    bool operator()(const value_type& __x, const value_type& __y) const {
78
      return comp(__x.first, __y.first);
79
    }
80
  };
81
 
82
private:
83
  typedef _Rb_tree
84
                  _Select1st, key_compare, _Alloc> _Rep_type;
85
  _Rep_type _M_t;  // red-black tree representing multimap
86
public:
87
  typedef typename _Rep_type::pointer pointer;
88
  typedef typename _Rep_type::const_pointer const_pointer;
89
  typedef typename _Rep_type::reference reference;
90
  typedef typename _Rep_type::const_reference const_reference;
91
  typedef typename _Rep_type::iterator iterator;
92
  typedef typename _Rep_type::const_iterator const_iterator;
93
  typedef typename _Rep_type::reverse_iterator reverse_iterator;
94
  typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
95
  typedef typename _Rep_type::size_type size_type;
96
  typedef typename _Rep_type::difference_type difference_type;
97
  typedef typename _Rep_type::allocator_type allocator_type;
98
 
99
// allocation/deallocation
100
 
101
  multimap() : _M_t(_Compare(), allocator_type()) { }
102
  explicit multimap(const _Compare& __comp,
103
                    const allocator_type& __a = allocator_type())
104
    : _M_t(__comp, __a) { }
105
 
106
  template 
107
  multimap(_InputIterator __first, _InputIterator __last)
108
    : _M_t(_Compare(), allocator_type())
109
    { _M_t.insert_equal(__first, __last); }
110
 
111
  template 
112
  multimap(_InputIterator __first, _InputIterator __last,
113
           const _Compare& __comp,
114
           const allocator_type& __a = allocator_type())
115
    : _M_t(__comp, __a) { _M_t.insert_equal(__first, __last); }
116
  multimap(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) { }
117
 
118
  multimap<_Key,_Tp,_Compare,_Alloc>&
119
  operator=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x) {
120
    _M_t = __x._M_t;
121
    return *this;
122
  }
123
 
124
  // accessors:
125
 
126
  key_compare key_comp() const { return _M_t.key_comp(); }
127
  value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
128
  allocator_type get_allocator() const { return _M_t.get_allocator(); }
129
 
130
  iterator begin() { return _M_t.begin(); }
131
  const_iterator begin() const { return _M_t.begin(); }
132
  iterator end() { return _M_t.end(); }
133
  const_iterator end() const { return _M_t.end(); }
134
  reverse_iterator rbegin() { return _M_t.rbegin(); }
135
  const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
136
  reverse_iterator rend() { return _M_t.rend(); }
137
  const_reverse_iterator rend() const { return _M_t.rend(); }
138
  bool empty() const { return _M_t.empty(); }
139
  size_type size() const { return _M_t.size(); }
140
  size_type max_size() const { return _M_t.max_size(); }
141
  void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
142
 
143
  // insert/erase
144
 
145
  iterator insert(const value_type& __x) { return _M_t.insert_equal(__x); }
146
  iterator insert(iterator __position, const value_type& __x) {
147
    return _M_t.insert_equal(__position, __x);
148
  }
149
  template 
150
  void insert(_InputIterator __first, _InputIterator __last) {
151
    _M_t.insert_equal(__first, __last);
152
  }
153
  void erase(iterator __position) { _M_t.erase(__position); }
154
  size_type erase(const key_type& __x) { return _M_t.erase(__x); }
155
  void erase(iterator __first, iterator __last)
156
    { _M_t.erase(__first, __last); }
157
  void clear() { _M_t.clear(); }
158
 
159
  // multimap operations:
160
 
161
  iterator find(const key_type& __x) { return _M_t.find(__x); }
162
  const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
163
  size_type count(const key_type& __x) const { return _M_t.count(__x); }
164
  iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }
165
  const_iterator lower_bound(const key_type& __x) const {
166
    return _M_t.lower_bound(__x);
167
  }
168
  iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }
169
  const_iterator upper_bound(const key_type& __x) const {
170
    return _M_t.upper_bound(__x);
171
  }
172
   pair equal_range(const key_type& __x) {
173
    return _M_t.equal_range(__x);
174
  }
175
  pair equal_range(const key_type& __x) const {
176
    return _M_t.equal_range(__x);
177
  }
178
 
179
  template 
180
  friend bool operator== (const multimap<_K1, _T1, _C1, _A1>&,
181
                          const multimap<_K1, _T1, _C1, _A1>&);
182
  template 
183
  friend bool operator< (const multimap<_K1, _T1, _C1, _A1>&,
184
                         const multimap<_K1, _T1, _C1, _A1>&);
185
};
186
 
187
template 
188
inline bool operator==(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
189
                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
190
  return __x._M_t == __y._M_t;
191
}
192
 
193
template 
194
inline bool operator<(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
195
                      const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
196
  return __x._M_t < __y._M_t;
197
}
198
 
199
template 
200
inline bool operator!=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
201
                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
202
  return !(__x == __y);
203
}
204
 
205
template 
206
inline bool operator>(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
207
                      const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
208
  return __y < __x;
209
}
210
 
211
template 
212
inline bool operator<=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
213
                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
214
  return !(__y < __x);
215
}
216
 
217
template 
218
inline bool operator>=(const multimap<_Key,_Tp,_Compare,_Alloc>& __x,
219
                       const multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
220
  return !(__x < __y);
221
}
222
 
223
template 
224
inline void swap(multimap<_Key,_Tp,_Compare,_Alloc>& __x,
225
                 multimap<_Key,_Tp,_Compare,_Alloc>& __y) {
226
  __x.swap(__y);
227
}
228
 
229
} // namespace std
230
 
231
#endif /* __SGI_STL_INTERNAL_MULTIMAP_H */
232
 
233
// Local Variables:
234
// mode:C++
235
// End: