unordered_set

Go to the documentation of this file.
00001 // TR1 unordered_set -*- C++ -*-
00002 
00003 // Copyright (C) 2005, 2006, 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/unordered_set
00031  *  This is a TR1 C++ Library header. 
00032  */
00033 
00034 #ifndef _TR1_UNORDERED_SET
00035 #define _TR1_UNORDERED_SET 1
00036 
00037 #include <tr1/hashtable>
00038 #include <tr1/functional_hash.h>
00039 
00040 namespace std
00041 { 
00042 _GLIBCXX_BEGIN_NAMESPACE(tr1)
00043 
00044   // XXX When we get typedef templates these class definitions
00045   // will be unnecessary.
00046   template<class _Value,
00047        class _Hash = hash<_Value>,
00048        class _Pred = std::equal_to<_Value>,
00049        class _Alloc = std::allocator<_Value>,
00050        bool __cache_hash_code = false>
00051     class unordered_set
00052     : public _Hashtable<_Value, _Value, _Alloc,
00053             std::_Identity<_Value>, _Pred,
00054             _Hash, __detail::_Mod_range_hashing,
00055             __detail::_Default_ranged_hash,
00056             __detail::_Prime_rehash_policy,
00057             __cache_hash_code, true, true>
00058     {
00059       typedef _Hashtable<_Value, _Value, _Alloc,
00060              std::_Identity<_Value>, _Pred,
00061              _Hash, __detail::_Mod_range_hashing,
00062              __detail::_Default_ranged_hash,
00063              __detail::_Prime_rehash_policy,
00064              __cache_hash_code, true, true>
00065         _Base;
00066 
00067     public:
00068       typedef typename _Base::size_type       size_type;
00069       typedef typename _Base::hasher          hasher;
00070       typedef typename _Base::key_equal       key_equal;
00071       typedef typename _Base::allocator_type  allocator_type;
00072       
00073       explicit
00074       unordered_set(size_type __n = 10,
00075             const hasher& __hf = hasher(),
00076             const key_equal& __eql = key_equal(),
00077             const allocator_type& __a = allocator_type())
00078       : _Base(__n, __hf, __detail::_Mod_range_hashing(),
00079           __detail::_Default_ranged_hash(), __eql,
00080           std::_Identity<_Value>(), __a)
00081       { }
00082 
00083       template<typename _InputIterator>
00084         unordered_set(_InputIterator __f, _InputIterator __l, 
00085               size_type __n = 10,
00086               const hasher& __hf = hasher(), 
00087               const key_equal& __eql = key_equal(), 
00088               const allocator_type& __a = allocator_type())
00089     : _Base(__f, __l, __n, __hf, __detail::_Mod_range_hashing(),
00090         __detail::_Default_ranged_hash(), __eql,
00091         std::_Identity<_Value>(), __a)
00092         { }
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 
00145   template<class _Value, class _Hash, class _Pred, class _Alloc,
00146        bool __cache_hash_code>
00147     inline void
00148     swap (unordered_set<_Value, _Hash, _Pred,
00149       _Alloc, __cache_hash_code>& __x,
00150       unordered_set<_Value, _Hash, _Pred,
00151       _Alloc, __cache_hash_code>& __y)
00152     { __x.swap(__y); }
00153 
00154   template<class _Value, class _Hash, class _Pred, class _Alloc,
00155        bool __cache_hash_code>
00156     inline void
00157     swap(unordered_multiset<_Value, _Hash, _Pred,
00158      _Alloc, __cache_hash_code>& __x,
00159      unordered_multiset<_Value, _Hash, _Pred,
00160      _Alloc, __cache_hash_code>& __y)
00161     { __x.swap(__y); }
00162 
00163 _GLIBCXX_END_NAMESPACE
00164 }
00165 
00166 #endif // _TR1_UNORDERED_SET

Generated on Thu Nov 1 13:12:50 2007 for libstdc++ by  doxygen 1.5.1