- Main Page
- Namespaces
- Classes
- Files
- Related Pages

# /Users/fpy/titan-1-5-MBARI/Mers/Executives/DeductiveController/Configs/TI_DSP_BIOS/stl/stl_map.h

    00001 /*
    00002  *
    00003  * Copyright (c) 1994
    00004  * Hewlett-Packard Company
    00005  *
    00006  * Permission to use, copy, modify, distribute and sell this software
    00007  * and its documentation for any purpose is hereby granted without fee,
    00008  * provided that the above copyright notice appear in all copies and
    00009  * that both that copyright notice and this permission notice appear
    00010  * in supporting documentation.  Hewlett-Packard Company makes no
    00011  * representations about the suitability of this software for any
    00012  * purpose.  It is provided "as is" without express or implied warranty.
    00013  *
    00014  *
    00015  * Copyright (c) 1996,1997
    00016  * Silicon Graphics Computer Systems, Inc.
    00017  *
    00018  * Permission to use, copy, modify, distribute and sell this software
    00019  * and its documentation for any purpose is hereby granted without fee,
    00020  * provided that the above copyright notice appear in all copies and
    00021  * that both that copyright notice and this permission notice appear
    00022  * in supporting documentation.  Silicon Graphics makes no
    00023  * representations about the suitability of this software for any
    00024  * purpose.  It is provided "as is" without express or implied warranty.
    00025  */
    00026
    00027 /* NOTE: This is an internal header file, included by other STL headers.
    00028  *   You should not attempt to use it directly.
    00029  */
    00030
    00031 #ifndef __SGI_STL_INTERNAL_MAP_H
    00032 #define __SGI_STL_INTERNAL_MAP_H
    00033
    00034 __STL_BEGIN_NAMESPACE
    00035
    00036 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    00037 #pragma set woff 1174
    00038 #pragma set woff 1375
    00039 #endif
    00040
    00041 #ifndef __STL_LIMITED_DEFAULT_TEMPLATES
    00042 template <class _Key, class _Tp, class _Compare = less<_Key>,
    00043           class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    00044 #else
    00045 template <class _Key, class _Tp, class _Compare,
    00046           class _Alloc = __STL_DEFAULT_ALLOCATOR(_Tp) >
    00047 #endif
    00048 class map {
    00049 public:
    00050
    00051 // typedefs:
    00052
    00053   typedef _Key                  key_type;
    00054   typedef _Tp                   data_type;
    00055   typedef _Tp                   mapped_type;
    00056   typedef pair<const _Key, _Tp> value_type;
    00057   typedef _Compare              key_compare;
    00058
    00059   class value_compare
    00060     : public binary_function<value_type, value_type, bool> {
    00061   friend class map<_Key,_Tp,_Compare,_Alloc>;
    00062   protected :
    00063     _Compare _M_comp;
    00064     value_compare(_Compare __c) : _M_comp(__c) {}
    00065   public:
    00066     bool operator()(const value_type& __x, const value_type& __y) const {
    00067       return _M_comp(__x.first, __y.first);
    00068     }
    00069   };
    00070
    00071 private:
    00072   typedef _Rb_tree<key_type, value_type,
    00073                    _Select1st<value_type>, key_compare, _Alloc> _Rep_type;
    00074   _Rep_type _M_t;  // red-black tree representing map
    00075 public:
    00076   typedef typename _Rep_type::pointer pointer;
    00077   typedef typename _Rep_type::const_pointer const_pointer;
    00078   typedef typename _Rep_type::reference reference;
    00079   typedef typename _Rep_type::const_reference const_reference;
    00080   typedef typename _Rep_type::iterator iterator;
    00081   typedef typename _Rep_type::const_iterator const_iterator;
    00082   typedef typename _Rep_type::reverse_iterator reverse_iterator;
    00083   typedef typename _Rep_type::const_reverse_iterator const_reverse_iterator;
    00084   typedef typename _Rep_type::size_type size_type;
    00085   typedef typename _Rep_type::difference_type difference_type;
    00086   typedef typename _Rep_type::allocator_type allocator_type;
    00087
    00088   // allocation/deallocation
    00089
    00090   map() : _M_t(_Compare(), allocator_type()) {}
    00091   explicit map(const _Compare& __comp,
    00092                const allocator_type& __a = allocator_type())
    00093     : _M_t(__comp, __a) {}
    00094
    00095 #ifdef __STL_MEMBER_TEMPLATES
    00096   template <class _InputIterator>
    00097   map(_InputIterator __first, _InputIterator __last)
    00098     : _M_t(_Compare(), allocator_type())
    00099     { _M_t.insert_unique(__first, __last); }
    00100
    00101   template <class _InputIterator>
    00102   map(_InputIterator __first, _InputIterator __last, const _Compare& __comp,
    00103       const allocator_type& __a = allocator_type())
    00104     : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
    00105 #else
    00106   map(const value_type* __first, const value_type* __last)
    00107     : _M_t(_Compare(), allocator_type())
    00108     { _M_t.insert_unique(__first, __last); }
    00109
    00110   map(const value_type* __first,
    00111       const value_type* __last, const _Compare& __comp,
    00112       const allocator_type& __a = allocator_type())
    00113     : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
    00114
    00115   map(const_iterator __first, const_iterator __last)
    00116     : _M_t(_Compare(), allocator_type())
    00117     { _M_t.insert_unique(__first, __last); }
    00118
    00119   map(const_iterator __first, const_iterator __last, const _Compare& __comp,
    00120       const allocator_type& __a = allocator_type())
    00121     : _M_t(__comp, __a) { _M_t.insert_unique(__first, __last); }
    00122
    00123 #endif /* __STL_MEMBER_TEMPLATES */
    00124
    00125   map(const map<_Key,_Tp,_Compare,_Alloc>& __x) : _M_t(__x._M_t) {}
    00126   map<_Key,_Tp,_Compare,_Alloc>&
    00127   operator=(const map<_Key, _Tp, _Compare, _Alloc>& __x)
    00128   {
    00129     _M_t = __x._M_t;
    00130     return *this;
    00131   }
    00132
    00133   // accessors:
    00134
    00135   key_compare key_comp() const { return _M_t.key_comp(); }
    00136   value_compare value_comp() const { return value_compare(_M_t.key_comp()); }
    00137   allocator_type get_allocator() const { return _M_t.get_allocator(); }
    00138
    00139   iterator begin() { return _M_t.begin(); }
    00140   const_iterator begin() const { return _M_t.begin(); }
    00141   iterator end() { return _M_t.end(); }
    00142   const_iterator end() const { return _M_t.end(); }
    00143   reverse_iterator rbegin() { return _M_t.rbegin(); }
    00144   const_reverse_iterator rbegin() const { return _M_t.rbegin(); }
    00145   reverse_iterator rend() { return _M_t.rend(); }
    00146   const_reverse_iterator rend() const { return _M_t.rend(); }
    00147   bool empty() const { return _M_t.empty(); }
    00148   size_type size() const { return _M_t.size(); }
    00149   size_type max_size() const { return _M_t.max_size(); }
    00150   _Tp& operator[](const key_type& __k) {
    00151     iterator __i = lower_bound(__k);
    00152     // __i->first is greater than or equivalent to __k.
    00153     if (__i == end() || key_comp()(__k, (*__i).first))
    00154       __i = insert(__i, value_type(__k, _Tp()));
    00155     return (*__i).second;
    00156   }
    00157   void swap(map<_Key,_Tp,_Compare,_Alloc>& __x) { _M_t.swap(__x._M_t); }
    00158
    00159   // insert/erase
    00160
    00161   pair<iterator,bool> insert(const value_type& __x)
    00162     { return _M_t.insert_unique(__x); }
    00163   iterator insert(iterator position, const value_type& __x)
    00164     { return _M_t.insert_unique(position, __x); }
    00165 #ifdef __STL_MEMBER_TEMPLATES
    00166   template <class _InputIterator>
    00167   void insert(_InputIterator __first, _InputIterator __last) {
    00168     _M_t.insert_unique(__first, __last);
    00169   }
    00170 #else
    00171   void insert(const value_type* __first, const value_type* __last) {
    00172     _M_t.insert_unique(__first, __last);
    00173   }
    00174   void insert(const_iterator __first, const_iterator __last) {
    00175     _M_t.insert_unique(__first, __last);
    00176   }
    00177 #endif /* __STL_MEMBER_TEMPLATES */
    00178
    00179   void erase(iterator __position) { _M_t.erase(__position); }
    00180   size_type erase(const key_type& __x) { return _M_t.erase(__x); }
    00181   void erase(iterator __first, iterator __last)
    00182     { _M_t.erase(__first, __last); }
    00183   void clear() { _M_t.clear(); }
    00184
    00185   // map operations:
    00186
    00187   iterator find(const key_type& __x) { return _M_t.find(__x); }
    00188   const_iterator find(const key_type& __x) const { return _M_t.find(__x); }
    00189   size_type count(const key_type& __x) const { return _M_t.count(__x); }
    00190   iterator lower_bound(const key_type& __x) {return _M_t.lower_bound(__x); }
    00191   const_iterator lower_bound(const key_type& __x) const {
    00192     return _M_t.lower_bound(__x);
    00193   }
    00194   iterator upper_bound(const key_type& __x) {return _M_t.upper_bound(__x); }
    00195   const_iterator upper_bound(const key_type& __x) const {
    00196     return _M_t.upper_bound(__x);
    00197   }
    00198
    00199   pair<iterator,iterator> equal_range(const key_type& __x) {
    00200     return _M_t.equal_range(__x);
    00201   }
    00202   pair<const_iterator,const_iterator> equal_range(const key_type& __x) const {
    00203     return _M_t.equal_range(__x);
    00204   }
    00205   friend bool operator== __STL_NULL_TMPL_ARGS (const map&, const map&);
    00206   friend bool operator< __STL_NULL_TMPL_ARGS (const map&, const map&);
    00207 };
    00208
    00209 template <class _Key, class _Tp, class _Compare, class _Alloc>
    00210 inline bool operator==(const map<_Key,_Tp,_Compare,_Alloc>& __x,
    00211                        const map<_Key,_Tp,_Compare,_Alloc>& __y) {
    00212   return __x._M_t == __y._M_t;
    00213 }
    00214
    00215 template <class _Key, class _Tp, class _Compare, class _Alloc>
    00216 inline bool operator<(const map<_Key,_Tp,_Compare,_Alloc>& __x,
    00217                       const map<_Key,_Tp,_Compare,_Alloc>& __y) {
    00218   return __x._M_t < __y._M_t;
    00219 }
    00220
    00221 #ifdef __STL_FUNCTION_TMPL_PARTIAL_ORDER
    00222
    00223 template <class _Key, class _Tp, class _Compare, class _Alloc>
    00224 inline void swap(map<_Key,_Tp,_Compare,_Alloc>& __x,
    00225                  map<_Key,_Tp,_Compare,_Alloc>& __y) {
    00226   __x.swap(__y);
    00227 }
    00228
    00229 #endif /* __STL_FUNCTION_TMPL_PARTIAL_ORDER */
    00230
    00231 #if defined(__sgi) && !defined(__GNUC__) && (_MIPS_SIM != _MIPS_SIM_ABI32)
    00232 #pragma reset woff 1174
    00233 #pragma reset woff 1375
    00234 #endif
    00235
    00236 __STL_END_NAMESPACE
    00237
    00238 #endif /* __SGI_STL_INTERNAL_MAP_H */
    00239
    00240 // Local Variables:
    00241 // mode:C++
    00242 // End: