tr1_impl/unordered_set

Go to the documentation of this file.
00001 // TR1 unordered_set -*- C++ -*-
00002 
00003 // Copyright (C) 2007 Free Software Foundation, Inc.
00004 //
00005 // This file is part of the GNU ISO C++ Library.  This library is free
00006 // software; you can redistribute it and/or modify it under the
00007 // terms of the GNU General Public License as published by the
00008 // Free Software Foundation; either version 2, or (at your option)
00009 // any later version.
00010 
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 
00016 // You should have received a copy of the GNU General Public License along
00017 // with this library; see the file COPYING.  If not, write to the Free
00018 // Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
00019 // USA.
00020 
00021 // As a special exception, you may use this file as part of a free software
00022 // library without restriction.  Specifically, if other files instantiate
00023 // templates or use macros or inline functions from this file, or you compile
00024 // this file and link it with other files to produce an executable, this
00025 // file does not by itself cause the resulting executable to be covered by
00026 // the GNU General Public License.  This exception does not however
00027 // invalidate any other reasons why the executable file might be covered by
00028 // the GNU General Public License.
00029 
00030 /** @file tr1_impl/unordered_set
00031  *  This is an internal header file, included by other library headers.
00032  *  You should not attempt to use it directly.
00033  */
00034 
00035 namespace std
00036 { 
00037 _GLIBCXX_BEGIN_NAMESPACE_TR1
00038 
00039   // XXX When we get typedef templates these class definitions
00040   // will be unnecessary.
00041   template<class _Value,
00042        class _Hash = hash<_Value>,
00043        class _Pred = std::equal_to<_Value>,
00044        class _Alloc = std::allocator<_Value>,
00045        bool __cache_hash_code = false>
00046     class __unordered_set
00047     : public _Hashtable<_Value, _Value, _Alloc,
00048             std::_Identity<_Value>, _Pred,
00049             _Hash, __detail::_Mod_range_hashing,
00050             __detail::_Default_ranged_hash,
00051             __detail::_Prime_rehash_policy,
00052             __cache_hash_code, true, true>
00053     {
00054       typedef _Hashtable<_Value, _Value, _Alloc,
00055              std::_Identity<_Value>, _Pred,
00056              _Hash, __detail::_Mod_range_hashing,
00057              __detail::_Default_ranged_hash,
00058              __detail::_Prime_rehash_policy,
00059              __cache_hash_code, true, true>
00060         _Base;
00061 
00062     public:
00063       typedef typename _Base::size_type       size_type;
00064       typedef typename _Base::hasher          hasher;
00065       typedef typename _Base::key_equal       key_equal;
00066       typedef typename _Base::allocator_type  allocator_type;
00067       
00068       explicit
00069       __unordered_set(size_type __n = 10,
00070               const hasher& __hf = hasher(),
00071               const key_equal& __eql = key_equal(),
00072               const allocator_type& __a = allocator_type())
00073       : _Base(__n, __hf, __detail::_Mod_range_hashing(),
00074           __detail::_Default_ranged_hash(), __eql,
00075           std::_Identity<_Value>(), __a)
00076       { }
00077 
00078       template<typename _InputIterator>
00079         __unordered_set(_InputIterator __f, _InputIterator __l, 
00080             size_type __n = 10,
00081             const hasher& __hf = hasher(), 
00082             const key_equal& __eql = key_equal(), 
00083             const allocator_type& __a = allocator_type())
00084     : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
00085         __detail::_Default_ranged_hash(), __eql,
00086         std::_Identity<_Value>(), __a)
00087         { }
00088 
00089 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00090       __unordered_set(__unordered_set&& __x)
00091       : _Base(std::forward<_Base>(__x)) { }
00092 #endif
00093     };
00094 
00095   template<class _Value,
00096        class _Hash = hash<_Value>,
00097        class _Pred = std::equal_to<_Value>,
00098        class _Alloc = std::allocator<_Value>,
00099        bool __cache_hash_code = false>
00100     class __unordered_multiset
00101     : public _Hashtable<_Value, _Value, _Alloc,
00102             std::_Identity<_Value>, _Pred,
00103             _Hash, __detail::_Mod_range_hashing,
00104             __detail::_Default_ranged_hash,
00105             __detail::_Prime_rehash_policy,
00106             __cache_hash_code, true, false>
00107     {
00108       typedef _Hashtable<_Value, _Value, _Alloc,
00109              std::_Identity<_Value>, _Pred,
00110              _Hash, __detail::_Mod_range_hashing,
00111              __detail::_Default_ranged_hash,
00112              __detail::_Prime_rehash_policy,
00113              __cache_hash_code, true, false>
00114         _Base;
00115 
00116     public:
00117       typedef typename _Base::size_type       size_type;
00118       typedef typename _Base::hasher          hasher;
00119       typedef typename _Base::key_equal       key_equal;
00120       typedef typename _Base::allocator_type  allocator_type;
00121       
00122       explicit
00123       __unordered_multiset(size_type __n = 10,
00124                const hasher& __hf = hasher(),
00125                const key_equal& __eql = key_equal(),
00126                const allocator_type& __a = allocator_type())
00127       : _Base(__n, __hf, __detail::_Mod_range_hashing(),
00128           __detail::_Default_ranged_hash(), __eql,
00129           std::_Identity<_Value>(), __a)
00130       { }
00131 
00132 
00133       template<typename _InputIterator>
00134         __unordered_multiset(_InputIterator __f, _InputIterator __l, 
00135                  typename _Base::size_type __n = 0,
00136                  const hasher& __hf = hasher(), 
00137                  const key_equal& __eql = key_equal(), 
00138                  const allocator_type& __a = allocator_type())
00139     : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
00140         __detail::_Default_ranged_hash(), __eql,
00141         std::_Identity<_Value>(), __a)
00142         { }
00143 
00144 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00145       __unordered_multiset(__unordered_multiset&& __x)
00146       : _Base(std::forward<_Base>(__x)) { }
00147 #endif
00148     };
00149 
00150   template<class _Value, class _Hash, class _Pred, class _Alloc,
00151        bool __cache_hash_code>
00152     inline void
00153     swap(__unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __x,
00154      __unordered_set<_Value, _Hash, _Pred, _Alloc, __cache_hash_code>& __y)
00155     { __x.swap(__y); }
00156 
00157   template<class _Value, class _Hash, class _Pred, class _Alloc,
00158        bool __cache_hash_code>
00159     inline void
00160     swap(__unordered_multiset<_Value, _Hash, _Pred,
00161      _Alloc, __cache_hash_code>& __x,
00162      __unordered_multiset<_Value, _Hash, _Pred,
00163      _Alloc, __cache_hash_code>& __y)
00164     { __x.swap(__y); }
00165 
00166 
00167   /// class unordered_set
00168   template<class _Value,
00169        class _Hash = hash<_Value>,
00170        class _Pred = std::equal_to<_Value>,
00171        class _Alloc = std::allocator<_Value> >
00172     class unordered_set
00173     : public __unordered_set<_Value, _Hash, _Pred, _Alloc>
00174     {
00175       typedef __unordered_set<_Value, _Hash, _Pred, _Alloc>  _Base;
00176 
00177     public:
00178       typedef typename _Base::size_type       size_type;
00179       typedef typename _Base::hasher          hasher;
00180       typedef typename _Base::key_equal       key_equal;
00181       typedef typename _Base::allocator_type  allocator_type;
00182       
00183       explicit
00184       unordered_set(size_type __n = 10,
00185             const hasher& __hf = hasher(),
00186             const key_equal& __eql = key_equal(),
00187             const allocator_type& __a = allocator_type())
00188       : _Base(__n, __hf, __eql, __a)
00189       { }
00190 
00191       template<typename _InputIterator>
00192         unordered_set(_InputIterator __f, _InputIterator __l, 
00193               size_type __n = 10,
00194               const hasher& __hf = hasher(), 
00195               const key_equal& __eql = key_equal(), 
00196               const allocator_type& __a = allocator_type())
00197     : _Base(__f, __l, __n, __hf, __eql, __a)
00198         { }
00199 
00200 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00201       unordered_set(unordered_set&& __x)
00202       : _Base(std::forward<_Base>(__x)) { }
00203 
00204       unordered_set&
00205       operator=(unordered_set&& __x)
00206       {
00207     // NB: DR 675.
00208     this->clear();
00209     this->swap(__x); 
00210     return *this;   
00211       }
00212 #endif
00213     };
00214 
00215   /// class unordered_multiset
00216   template<class _Value,
00217        class _Hash = hash<_Value>,
00218        class _Pred = std::equal_to<_Value>,
00219        class _Alloc = std::allocator<_Value> >
00220     class unordered_multiset
00221     : public __unordered_multiset<_Value, _Hash, _Pred, _Alloc>
00222     {
00223       typedef __unordered_multiset<_Value, _Hash, _Pred, _Alloc>  _Base;
00224 
00225     public:
00226       typedef typename _Base::size_type       size_type;
00227       typedef typename _Base::hasher          hasher;
00228       typedef typename _Base::key_equal       key_equal;
00229       typedef typename _Base::allocator_type  allocator_type;
00230       
00231       explicit
00232       unordered_multiset(size_type __n = 10,
00233              const hasher& __hf = hasher(),
00234              const key_equal& __eql = key_equal(),
00235              const allocator_type& __a = allocator_type())
00236       : _Base(__n, __hf, __eql, __a)
00237       { }
00238 
00239 
00240       template<typename _InputIterator>
00241         unordered_multiset(_InputIterator __f, _InputIterator __l, 
00242                typename _Base::size_type __n = 0,
00243                const hasher& __hf = hasher(), 
00244                const key_equal& __eql = key_equal(), 
00245                const allocator_type& __a = allocator_type())
00246     : _Base(__f, __l, __n, __hf, __eql, __a)
00247         { }
00248 
00249 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00250       unordered_multiset(unordered_multiset&& __x)
00251       : _Base(std::forward<_Base>(__x)) { }
00252 
00253       unordered_multiset&
00254       operator=(unordered_multiset&& __x)
00255       {
00256     // NB: DR 675.
00257     this->clear();
00258     this->swap(__x); 
00259     return *this;   
00260       }
00261 #endif
00262     };
00263 
00264   template<class _Value, class _Hash, class _Pred, class _Alloc>
00265     inline void
00266     swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
00267      unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
00268     { __x.swap(__y); }
00269 
00270   template<class _Value, class _Hash, class _Pred, class _Alloc>
00271     inline void
00272     swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
00273      unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
00274     { __x.swap(__y); }
00275 
00276 #ifdef _GLIBCXX_INCLUDE_AS_CXX0X
00277   template<class _Value, class _Hash, class _Pred, class _Alloc>
00278     inline void
00279     swap(unordered_set<_Value, _Hash, _Pred, _Alloc>&& __x,
00280      unordered_set<_Value, _Hash, _Pred, _Alloc>& __y)
00281     { __x.swap(__y); }
00282 
00283   template<class _Value, class _Hash, class _Pred, class _Alloc>
00284     inline void
00285     swap(unordered_set<_Value, _Hash, _Pred, _Alloc>& __x,
00286      unordered_set<_Value, _Hash, _Pred, _Alloc>&& __y)
00287     { __x.swap(__y); }
00288 
00289   template<class _Value, class _Hash, class _Pred, class _Alloc>
00290     inline void
00291     swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __x,
00292      unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __y)
00293     { __x.swap(__y); }
00294 
00295   template<class _Value, class _Hash, class _Pred, class _Alloc>
00296     inline void
00297     swap(unordered_multiset<_Value, _Hash, _Pred, _Alloc>& __x,
00298      unordered_multiset<_Value, _Hash, _Pred, _Alloc>&& __y)
00299     { __x.swap(__y); }
00300 #endif
00301 
00302 _GLIBCXX_END_NAMESPACE_TR1
00303 }

Generated on Wed Mar 26 00:43:27 2008 for libstdc++ by  doxygen 1.5.1