unordered_set

Go to the documentation of this file.
00001 // TR1 unordered_set -*- C++ -*-
00002 
00003 // Copyright (C) 2005 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 
00034 #ifndef GNU_LIBSTDCXX_TR1_UNORDERED_SET_
00035 #define GNU_LIBSTDCXX_TR1_UNORDERED_SET_
00036 
00037 #include <tr1/hashtable>
00038 #include <tr1/functional>
00039 #include <memory>
00040 
00041 namespace std
00042 { 
00043 namespace tr1
00044 {
00045 
00046   // XXX When we get typedef templates these class definitions
00047   // will be unnecessary.
00048 
00049   template<class Value,
00050        class Hash = hash<Value>,
00051        class Pred = std::equal_to<Value>,
00052        class Alloc = std::allocator<Value>,
00053        bool cache_hash_code = false>
00054     class unordered_set
00055     : public hashtable<Value, Value, Alloc,
00056                Internal::identity<Value>, Pred,
00057                Hash, Internal::mod_range_hashing,
00058                Internal::default_ranged_hash,
00059                Internal::prime_rehash_policy,
00060                cache_hash_code, true, true>
00061     {
00062       typedef hashtable<Value, Value, Alloc,
00063             Internal::identity<Value>, Pred,
00064             Hash, Internal::mod_range_hashing,
00065             Internal::default_ranged_hash,
00066             Internal::prime_rehash_policy,
00067             cache_hash_code, true, true>
00068         Base;
00069 
00070     public:
00071       typedef typename Base::size_type size_type;
00072       typedef typename Base::hasher hasher;
00073       typedef typename Base::key_equal key_equal;
00074       typedef typename Base::allocator_type allocator_type;
00075       
00076       explicit
00077       unordered_set(size_type n = 10,
00078             const hasher& hf = hasher(),
00079             const key_equal& eql = key_equal(),
00080             const allocator_type& a = allocator_type())
00081       : Base (n, hf, Internal::mod_range_hashing(),
00082           Internal::default_ranged_hash(),
00083           eql, Internal::identity<Value>(), a)
00084       { }
00085 
00086       template<typename InputIterator>
00087         unordered_set(InputIterator f, InputIterator l, 
00088               size_type n = 10,
00089               const hasher& hf = hasher(), 
00090               const key_equal& eql = key_equal(), 
00091               const allocator_type& a = allocator_type())
00092     : Base (f, l, n, hf, Internal::mod_range_hashing(),
00093         Internal::default_ranged_hash(),
00094         eql, Internal::identity<Value>(), a)
00095         { }
00096     };
00097 
00098   template<class Value,
00099        class Hash = hash<Value>,
00100        class Pred = std::equal_to<Value>,
00101        class Alloc = std::allocator<Value>,
00102        bool cache_hash_code = false>
00103     class unordered_multiset
00104     : public hashtable <Value, Value, Alloc,
00105             Internal::identity<Value>, Pred,
00106             Hash, Internal::mod_range_hashing,
00107             Internal::default_ranged_hash,
00108             Internal::prime_rehash_policy,
00109             cache_hash_code, true, false>
00110     {
00111       typedef hashtable<Value, Value, Alloc,
00112             Internal::identity<Value>, Pred,
00113             Hash, Internal::mod_range_hashing,
00114             Internal::default_ranged_hash,
00115             Internal::prime_rehash_policy,
00116             cache_hash_code, true, false>
00117         Base;
00118 
00119     public:
00120       typedef typename Base::size_type size_type;
00121       typedef typename Base::hasher hasher;
00122       typedef typename Base::key_equal key_equal;
00123       typedef typename Base::allocator_type allocator_type;
00124       
00125       explicit
00126       unordered_multiset(size_type n = 10,
00127              const hasher& hf = hasher(),
00128              const key_equal& eql = key_equal(),
00129              const allocator_type& a = allocator_type())
00130       : Base (n, hf, Internal::mod_range_hashing(),
00131           Internal::default_ranged_hash(),
00132           eql, Internal::identity<Value>(), a)
00133       { }
00134 
00135 
00136       template<typename InputIterator>
00137         unordered_multiset(InputIterator f, InputIterator l, 
00138                typename Base::size_type n = 0,
00139                const hasher& hf = hasher(), 
00140                const key_equal& eql = key_equal(), 
00141                const allocator_type& a = allocator_type())
00142     : Base (f, l, n, hf, Internal::mod_range_hashing(),
00143         Internal::default_ranged_hash(), eql,
00144         Internal::identity<Value>(), a)
00145         { }
00146     };
00147 
00148   template<class Value, class Hash, class Pred, class Alloc,
00149        bool cache_hash_code>
00150     inline void
00151     swap (unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& x,
00152       unordered_set<Value, Hash, Pred, Alloc, cache_hash_code>& y)
00153     { x.swap(y); }
00154 
00155   template<class Value, class Hash, class Pred, class Alloc,
00156        bool cache_hash_code>
00157     inline void
00158     swap(unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& x,
00159      unordered_multiset<Value, Hash, Pred, Alloc, cache_hash_code>& y)
00160    { x.swap(y); }
00161 
00162 }
00163 }
00164 
00165 #endif /* GNU_LIBSTDCXX_TR1_UNORDERED_SET_ */

Generated on Tue Feb 2 16:56:53 2010 for GNU C++ STL by  doxygen 1.4.7