assoc_container.hpp

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005, 2006, 2009, 2010 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 terms
00007 // of the GNU General Public License as published by the Free Software
00008 // Foundation; either version 3, or (at your option) any later
00009 // version.
00010 
00011 // This library is distributed in the hope that it will be useful, but
00012 // WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // General Public License for more details.
00015 
00016 // Under Section 7 of GPL version 3, you are granted additional
00017 // permissions described in the GCC Runtime Library Exception, version
00018 // 3.1, as published by the Free Software Foundation.
00019 
00020 // You should have received a copy of the GNU General Public License and
00021 // a copy of the GCC Runtime Library Exception along with this program;
00022 // see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
00023 // <http://www.gnu.org/licenses/>.
00024 
00025 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
00026 
00027 // Permission to use, copy, modify, sell, and distribute this software
00028 // is hereby granted without fee, provided that the above copyright
00029 // notice appears in all copies, and that both that copyright notice
00030 // and this permission notice appear in supporting documentation. None
00031 // of the above authors, nor IBM Haifa Research Laboratories, make any
00032 // representation about the suitability of this software for any
00033 // purpose. It is provided "as is" without express or implied
00034 // warranty.
00035 
00036 /**
00037  * @file assoc_container.hpp
00038  * Contains associative containers.
00039  */
00040 
00041 #ifndef PB_DS_ASSOC_CNTNR_HPP
00042 #define PB_DS_ASSOC_CNTNR_HPP
00043 
00044 #include <ext/typelist.h>
00045 #include <ext/pb_ds/tag_and_trait.hpp>
00046 #include <ext/pb_ds/detail/standard_policies.hpp>
00047 #include <ext/pb_ds/detail/container_base_dispatch.hpp>
00048 #include <ext/pb_ds/detail/basic_tree_policy/traits.hpp>
00049 
00050 namespace __gnu_pbds
00051 {
00052   /** @defgroup pbds Policy-Based Data Structures
00053    *  @ingroup extensions
00054    *
00055    *  This is a library of policy-based elementary data structures:
00056    *  associative containers and priority queues. It is designed for
00057    *  high-performance, flexibility, semantic safety, and conformance
00058    *  to the corresponding containers in std (except for some points
00059    *  where it differs by design).
00060    *
00061    *  For details, see: 
00062    *  http://gcc.gnu.org/onlinedocs/libstdc++/ext/pb_ds/index.html
00063    *
00064    *  @{
00065    */
00066  
00067 #define PB_DS_BASE_C_DEC \
00068   detail::container_base_dispatch<Key, Mapped, Tag, Policy_Tl, Allocator>::type
00069 
00070   /// An abstract basic associative container.
00071   template<typename Key, 
00072        typename Mapped, 
00073        typename Tag, 
00074        typename Policy_Tl, 
00075        typename Allocator>
00076   class container_base : public PB_DS_BASE_C_DEC
00077   {
00078   private:
00079     typedef typename PB_DS_BASE_C_DEC           base_type;
00080 
00081   public:
00082     typedef Tag                     container_category;
00083     typedef Allocator                   allocator_type;
00084     typedef typename allocator_type::size_type      size_type;
00085     typedef typename allocator_type::difference_type    difference_type;
00086 
00087     // key_type
00088     typedef typename allocator_type::template rebind<Key>::other::value_type key_type;
00089     typedef typename allocator_type::template rebind<key_type>::other key_rebind;
00090     typedef typename key_rebind::reference      key_reference;
00091     typedef typename key_rebind::const_reference    const_key_reference;
00092     typedef typename key_rebind::pointer        key_pointer;
00093     typedef typename key_rebind::const_pointer      const_key_pointer;
00094 
00095     // mapped_type
00096     typedef Mapped                  mapped_type;
00097     typedef typename allocator_type::template rebind<mapped_type>::other mapped_rebind;
00098     typedef typename mapped_rebind::reference       mapped_reference;
00099     typedef typename mapped_rebind::const_reference const_mapped_reference;
00100     typedef typename mapped_rebind::pointer         mapped_pointer;
00101     typedef typename mapped_rebind::const_pointer   const_mapped_pointer;
00102 
00103     // value_type
00104     typedef typename base_type::value_type      value_type;
00105     typedef typename allocator_type::template rebind<value_type>::other value_rebind;
00106     typedef typename value_rebind::reference        reference;
00107     typedef typename value_rebind::const_reference  const_reference;
00108     typedef typename value_rebind::pointer      pointer;
00109     typedef typename value_rebind::const_pointer    const_pointer;
00110 
00111     // iterators
00112     typedef typename base_type::iterator        iterator;
00113     typedef typename base_type::const_iterator      const_iterator;
00114     typedef typename base_type::point_iterator      point_iterator;
00115     typedef typename base_type::const_point_iterator    const_point_iterator;
00116 
00117     virtual
00118     ~container_base() { }
00119 
00120   protected:
00121 #define PB_DS_CLASS_NAME        container_base
00122 #include <ext/pb_ds/detail/constructors_destructor_fn_imps.hpp>
00123 #undef PB_DS_CLASS_NAME
00124   };
00125 
00126 #undef PB_DS_BASE_C_DEC
00127 
00128 
00129 #define PB_DS_BASE_C_DEC \
00130   container_base<Key, Mapped, Tag, typename __gnu_cxx::typelist::append< \
00131   typename __gnu_cxx::typelist::create4<Hash_Fn, Eq_Fn, Resize_Policy, detail::integral_constant<int, Store_Hash> >::type, Policy_TL>::type, Allocator>
00132 
00133   /// An abstract basic hash-based associative container.
00134   template<typename Key,
00135        typename Mapped,
00136        typename Hash_Fn,
00137        typename Eq_Fn,
00138        typename Resize_Policy,
00139        bool Store_Hash,
00140        typename Tag,
00141        typename Policy_TL,
00142        typename Allocator>
00143   class basic_hash_table : public PB_DS_BASE_C_DEC
00144   {
00145   private:
00146     typedef PB_DS_BASE_C_DEC base_type;
00147 
00148   public:
00149     virtual
00150     ~basic_hash_table() { }
00151 
00152   protected:
00153 #define PB_DS_CLASS_NAME basic_hash_table
00154 #include <ext/pb_ds/detail/constructors_destructor_fn_imps.hpp>
00155 #undef PB_DS_CLASS_NAME
00156 
00157   private:
00158     basic_hash_table& 
00159     operator=(const base_type&);
00160   };
00161 
00162 #undef PB_DS_BASE_C_DEC
00163 
00164 
00165 #define PB_DS_BASE_C_DEC \
00166   basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
00167            cc_hash_tag, \
00168       typename __gnu_cxx::typelist::create1<Comb_Hash_Fn>::type, Allocator>
00169 
00170   /// A concrete collision-chaining hash-based associative container.
00171   template<typename Key,
00172        typename Mapped,
00173        typename Hash_Fn = typename detail::default_hash_fn<Key>::type,
00174        typename Eq_Fn = typename detail::default_eq_fn<Key>::type,
00175        typename Comb_Hash_Fn = detail::default_comb_hash_fn::type,
00176        typename Resize_Policy = typename detail::default_resize_policy<Comb_Hash_Fn>::type,
00177        bool Store_Hash = detail::default_store_hash,
00178        typename Allocator = std::allocator<char> >
00179   class cc_hash_table :  public PB_DS_BASE_C_DEC
00180   {
00181   private:
00182     typedef PB_DS_BASE_C_DEC    base_type;
00183 
00184   public:
00185     typedef Hash_Fn         hash_fn;
00186     typedef Eq_Fn       eq_fn;
00187     typedef Resize_Policy   resize_policy;
00188     typedef Comb_Hash_Fn    comb_hash_fn;
00189 
00190     // Default constructor.
00191     cc_hash_table() { }
00192 
00193     // Constructor taking some policy objects. r_hash_fn will be
00194     // copied by the Hash_Fn object of the container object.
00195     cc_hash_table(const hash_fn& h) 
00196     : base_type(h) { }
00197 
00198     // Constructor taking some policy objects. r_hash_fn will be
00199     // copied by the hash_fn object of the container object, and
00200     // r_eq_fn will be copied by the eq_fn object of the container
00201     // object.
00202     cc_hash_table(const hash_fn& h, const eq_fn& e)
00203     : base_type(h, e) { }
00204 
00205     // Constructor taking some policy objects. r_hash_fn will be
00206     // copied by the hash_fn object of the container object, r_eq_fn
00207     // will be copied by the eq_fn object of the container object, and
00208     // r_comb_hash_fn will be copied by the comb_hash_fn object of the
00209     // container object.
00210     cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch)
00211     : base_type(h, e, ch) { }
00212 
00213     // Constructor taking some policy objects. r_hash_fn will be
00214     // copied by the hash_fn object of the container object, r_eq_fn
00215     // will be copied by the eq_fn object of the container object,
00216     // r_comb_hash_fn will be copied by the comb_hash_fn object of the
00217     // container object, and r_resize_policy will be copied by the
00218     // resize_policy object of the container object.
00219     cc_hash_table(const hash_fn& h, const eq_fn& e, const comb_hash_fn& ch, 
00220           const resize_policy& rp)    
00221     : base_type(h, e, ch, rp) { }
00222 
00223     // Constructor taking __iterators to a range of value_types. The
00224     // value_types between first_it and last_it will be inserted into
00225     // the container object.
00226     template<typename It>
00227     cc_hash_table(It first, It last)
00228     { base_type::copy_from_range(first, last); }
00229 
00230     // Constructor taking __iterators to a range of value_types and
00231     // some policy objects. The value_types between first_it and
00232     // last_it will be inserted into the container object.
00233     template<typename It>
00234     cc_hash_table(It first, It last, const hash_fn& h)
00235     : base_type(h)
00236     { copy_from_range(first, last); }
00237 
00238     // Constructor taking __iterators to a range of value_types and
00239     // some policy objects The value_types between first_it and
00240     // last_it will be inserted into the container object. r_hash_fn
00241     // will be copied by the hash_fn object of the container object,
00242     // and r_eq_fn will be copied by the eq_fn object of the container
00243     // object.
00244     template<typename It>
00245     cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e)
00246     : base_type(h, e)
00247     { copy_from_range(first, last); }
00248 
00249     // Constructor taking __iterators to a range of value_types and
00250     // some policy objects The value_types between first_it and
00251     // last_it will be inserted into the container object. r_hash_fn
00252     // will be copied by the hash_fn object of the container object,
00253     // r_eq_fn will be copied by the eq_fn object of the container
00254     // object, and r_comb_hash_fn will be copied by the comb_hash_fn
00255     // object of the container object.
00256     template<typename It>
00257     cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e,
00258           const comb_hash_fn& ch)
00259     : base_type(h, e, ch)
00260     { copy_from_range(first, last); }
00261 
00262     // Constructor taking __iterators to a range of value_types and
00263     // some policy objects The value_types between first_it and
00264     // last_it will be inserted into the container object. r_hash_fn
00265     // will be copied by the hash_fn object of the container object,
00266     // r_eq_fn will be copied by the eq_fn object of the container
00267     // object, r_comb_hash_fn will be copied by the comb_hash_fn
00268     // object of the container object, and r_resize_policy will be
00269     // copied by the resize_policy object of the container object.
00270     template<typename It>
00271     cc_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, 
00272           const comb_hash_fn& ch, const resize_policy& rp)
00273     : base_type(h, e, ch, rp)
00274     { copy_from_range(first, last); }
00275 
00276     cc_hash_table(const cc_hash_table& other)
00277     : base_type((const base_type&)other)
00278     { }
00279 
00280     virtual
00281     ~cc_hash_table() { }
00282 
00283     cc_hash_table& 
00284     operator=(const cc_hash_table& other)
00285     {
00286       if (this != &other)
00287     {
00288       cc_hash_table tmp(other);
00289       swap(tmp);
00290     }
00291       return *this;
00292     }
00293 
00294     void
00295     swap(cc_hash_table& other)
00296     { base_type::swap(other); }
00297   };
00298 
00299 #undef PB_DS_BASE_C_DEC
00300 
00301 
00302 #define PB_DS_BASE_C_DEC \
00303   basic_hash_table<Key, Mapped, Hash_Fn, Eq_Fn, Resize_Policy, Store_Hash, \
00304            gp_hash_tag, \
00305            typename __gnu_cxx::typelist::create2<Comb_Probe_Fn, Probe_Fn>::type, Allocator>
00306 
00307   /// A concrete general-probing hash-based associative container.
00308   template<typename Key,
00309        typename Mapped,
00310        typename Hash_Fn = typename detail::default_hash_fn<Key>::type,
00311        typename Eq_Fn = typename detail::default_eq_fn<Key>::type,
00312        typename Comb_Probe_Fn = detail::default_comb_hash_fn::type,
00313        typename Probe_Fn = typename detail::default_probe_fn<Comb_Probe_Fn>::type,
00314        typename Resize_Policy = typename detail::default_resize_policy<Comb_Probe_Fn>::type,
00315        bool Store_Hash = detail::default_store_hash,
00316        typename Allocator = std::allocator<char> >
00317   class gp_hash_table : public PB_DS_BASE_C_DEC
00318   {
00319   private:
00320     typedef PB_DS_BASE_C_DEC    base_type;
00321 
00322   public:
00323     typedef Hash_Fn         hash_fn;
00324     typedef Eq_Fn       eq_fn;
00325     typedef Comb_Probe_Fn   comb_probe_fn;
00326     typedef Probe_Fn        probe_fn;
00327     typedef Resize_Policy   resize_policy;
00328 
00329     // Default constructor.
00330     gp_hash_table() { }
00331 
00332     // Constructor taking some policy objects. r_hash_fn will be
00333     // copied by the hash_fn object of the container object.
00334     gp_hash_table(const hash_fn& h)
00335     : base_type(h) { }
00336 
00337     // Constructor taking some policy objects. r_hash_fn will be
00338     // copied by the hash_fn object of the container object, and
00339     // r_eq_fn will be copied by the eq_fn object of the container
00340     // object.
00341     gp_hash_table(const hash_fn& h, const eq_fn& e)
00342     : base_type(h, e) { }
00343 
00344     // Constructor taking some policy objects. r_hash_fn will be
00345     // copied by the hash_fn object of the container object, r_eq_fn
00346     // will be copied by the eq_fn object of the container object, and
00347     // r_comb_probe_fn will be copied by the comb_probe_fn object of
00348     // the container object.
00349     gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp)
00350     : base_type(h, e, cp) { }
00351 
00352     // Constructor taking some policy objects. r_hash_fn will be
00353     // copied by the hash_fn object of the container object, r_eq_fn
00354     // will be copied by the eq_fn object of the container object,
00355     // r_comb_probe_fn will be copied by the comb_probe_fn object of
00356     // the container object, and r_probe_fn will be copied by the
00357     // probe_fn object of the container object.
00358     gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp, 
00359           const probe_fn& p)
00360     : base_type(h, e, cp, p) { }
00361 
00362     // Constructor taking some policy objects. r_hash_fn will be
00363     // copied by the hash_fn object of the container object, r_eq_fn
00364     // will be copied by the eq_fn object of the container object,
00365     // r_comb_probe_fn will be copied by the comb_probe_fn object of
00366     // the container object, r_probe_fn will be copied by the probe_fn
00367     // object of the container object, and r_resize_policy will be
00368     // copied by the Resize_Policy object of the container object.
00369     gp_hash_table(const hash_fn& h, const eq_fn& e, const comb_probe_fn& cp, 
00370           const probe_fn& p, const resize_policy& rp)
00371     : base_type(h, e, cp, p, rp) { }
00372 
00373     // Constructor taking __iterators to a range of value_types. The
00374     // value_types between first_it and last_it will be inserted into
00375     // the container object.
00376     template<typename It>
00377     gp_hash_table(It first, It last)
00378     { base_type::copy_from_range(first, last); }
00379 
00380     // Constructor taking __iterators to a range of value_types and
00381     // some policy objects. The value_types between first_it and
00382     // last_it will be inserted into the container object. r_hash_fn
00383     // will be copied by the hash_fn object of the container object.
00384     template<typename It>
00385     gp_hash_table(It first, It last, const hash_fn& h)
00386     : base_type(h)
00387     { base_type::copy_from_range(first, last); }
00388 
00389     // Constructor taking __iterators to a range of value_types and
00390     // some policy objects. The value_types between first_it and
00391     // last_it will be inserted into the container object. r_hash_fn
00392     // will be copied by the hash_fn object of the container object,
00393     // and r_eq_fn will be copied by the eq_fn object of the container
00394     // object.
00395     template<typename It>
00396     gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e)
00397     : base_type(h, e)
00398     { base_type::copy_from_range(first, last); }
00399 
00400     // Constructor taking __iterators to a range of value_types and
00401     // some policy objects. The value_types between first_it and
00402     // last_it will be inserted into the container object. r_hash_fn
00403     // will be copied by the hash_fn object of the container object,
00404     // r_eq_fn will be copied by the eq_fn object of the container
00405     // object, and r_comb_probe_fn will be copied by the comb_probe_fn
00406     // object of the container object.
00407     template<typename It>
00408     gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, 
00409           const comb_probe_fn& cp)
00410     : base_type(h, e, cp)
00411     { base_type::copy_from_range(first, last); }
00412 
00413     // Constructor taking __iterators to a range of value_types and
00414     // some policy objects. The value_types between first_it and
00415     // last_it will be inserted into the container object. r_hash_fn
00416     // will be copied by the hash_fn object of the container object,
00417     // r_eq_fn will be copied by the eq_fn object of the container
00418     // object, r_comb_probe_fn will be copied by the comb_probe_fn
00419     // object of the container object, and r_probe_fn will be copied
00420     // by the probe_fn object of the container object.
00421     template<typename It>
00422     gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, 
00423           const comb_probe_fn& cp, const probe_fn& p)
00424     : base_type(h, e, cp, p)
00425     { base_type::copy_from_range(first, last); }
00426 
00427     // Constructor taking __iterators to a range of value_types and
00428     // some policy objects. The value_types between first_it and
00429     // last_it will be inserted into the container object. r_hash_fn
00430     // will be copied by the hash_fn object of the container object,
00431     // r_eq_fn will be copied by the eq_fn object of the container
00432     // object, r_comb_probe_fn will be copied by the comb_probe_fn
00433     // object of the container object, r_probe_fn will be copied by
00434     // the probe_fn object of the container object, and
00435     // r_resize_policy will be copied by the resize_policy object of
00436     // the container object.
00437     template<typename It>
00438     gp_hash_table(It first, It last, const hash_fn& h, const eq_fn& e, 
00439           const comb_probe_fn& cp, const probe_fn& p, 
00440           const resize_policy& rp)
00441     : base_type(h, e, cp, p, rp)
00442     { base_type::copy_from_range(first, last); }
00443 
00444     gp_hash_table(const gp_hash_table& other)
00445     : base_type((const base_type&)other)
00446     { }
00447 
00448     virtual
00449     ~gp_hash_table() { }
00450 
00451     gp_hash_table& 
00452     operator=(const gp_hash_table& other)
00453     {
00454       if (this != &other)
00455     {
00456       gp_hash_table tmp(other);
00457       swap(tmp);
00458     }
00459       return *this;
00460     }
00461 
00462     void
00463     swap(gp_hash_table& other)
00464     { base_type::swap(other); }
00465   };
00466 
00467 #undef PB_DS_BASE_C_DEC
00468 
00469 
00470 #define PB_DS_BASE_C_DEC \
00471   container_base<Key, Mapped, Tag, Policy_Tl, Allocator>
00472 
00473   /// An abstract basic tree-like (tree, trie) associative container.
00474   template<typename Key, typename Mapped, typename Tag, 
00475        typename Node_Update, typename Policy_Tl, typename Allocator>
00476   class basic_tree : public PB_DS_BASE_C_DEC
00477   {
00478   private:
00479     typedef PB_DS_BASE_C_DEC    base_type;
00480 
00481   public:
00482     typedef Node_Update     node_update;
00483 
00484     virtual
00485     ~basic_tree() { }
00486 
00487   protected:
00488 #define PB_DS_CLASS_NAME        basic_tree
00489 #include <ext/pb_ds/detail/constructors_destructor_fn_imps.hpp>
00490 #undef PB_DS_CLASS_NAME
00491   };
00492 
00493 #undef PB_DS_BASE_C_DEC
00494 
00495 
00496 #define PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC \
00497   detail::tree_traits<Key, Mapped,Cmp_Fn,Node_Update,Tag, Allocator>
00498 
00499 #define PB_DS_BASE_C_DEC \
00500   basic_tree<Key,Mapped,Tag,typename PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC::node_update, \
00501          typename __gnu_cxx::typelist::create2<Cmp_Fn, PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC >::type, Allocator>
00502 
00503   /// A concrete basic tree-based associative container.
00504   template<typename Key, typename Mapped, typename Cmp_Fn = std::less<Key>,
00505        typename Tag = rb_tree_tag,
00506        template<typename Const_Node_Iterator, typename Node_Iterator, typename Cmp_Fn_, typename Allocator_>
00507   class Node_Update = __gnu_pbds::null_tree_node_update,
00508        typename Allocator = std::allocator<char> >
00509   class tree : public PB_DS_BASE_C_DEC
00510   {
00511   private:
00512     typedef PB_DS_BASE_C_DEC    base_type;
00513 
00514   public:
00515     // Comparison functor type.
00516     typedef Cmp_Fn      cmp_fn;
00517 
00518     tree() { }
00519 
00520     // Constructor taking some policy objects. r_cmp_fn will be copied
00521     // by the Cmp_Fn object of the container object.
00522     tree(const cmp_fn& c)
00523     : base_type(c) { }
00524 
00525     // Constructor taking __iterators to a range of value_types. The
00526     // value_types between first_it and last_it will be inserted into
00527     // the container object.
00528     template<typename It>
00529     tree(It first, It last)
00530     { base_type::copy_from_range(first, last); }
00531 
00532     // Constructor taking __iterators to a range of value_types and
00533     // some policy objects The value_types between first_it and
00534     // last_it will be inserted into the container object. r_cmp_fn
00535     // will be copied by the cmp_fn object of the container object.
00536     template<typename It>
00537     tree(It first, It last, const cmp_fn& c)
00538       : base_type(c)
00539     { base_type::copy_from_range(first, last); }
00540 
00541     tree(const tree& other)
00542     : base_type((const base_type&)other) { }
00543 
00544     virtual
00545     ~tree() { }
00546 
00547     tree& 
00548     operator=(const tree& other)
00549     {
00550       if (this != &other)
00551     {
00552       tree tmp(other);
00553       swap(tmp);
00554     }
00555       return *this;
00556     }
00557 
00558     void
00559     swap(tree& other)
00560     { base_type::swap(other); }
00561   };
00562 
00563 #undef PB_DS_BASE_C_DEC
00564 #undef PB_DS_TREE_NODE_AND_IT_TRAITS_C_DEC
00565 
00566 
00567 #define PB_DS_TRIE_NODE_AND_ITS_TRAITS \
00568   detail::trie_traits<Key,Mapped,E_Access_Traits,Node_Update,Tag,Allocator>
00569 
00570 #define PB_DS_BASE_C_DEC \
00571   basic_tree<Key,Mapped,Tag, typename PB_DS_TRIE_NODE_AND_ITS_TRAITS::node_update, \
00572          typename __gnu_cxx::typelist::create2<E_Access_Traits, PB_DS_TRIE_NODE_AND_ITS_TRAITS >::type, Allocator>
00573 
00574   /// A concrete basic trie-based associative container.
00575   template<typename Key,
00576        typename Mapped,
00577        typename E_Access_Traits = typename detail::default_trie_e_access_traits<Key>::type,
00578        typename Tag = pat_trie_tag,
00579        template<typename Const_Node_Iterator,
00580             typename Node_Iterator,
00581             typename E_Access_Traits_,
00582             typename Allocator_>
00583   class Node_Update = null_trie_node_update,
00584        typename Allocator = std::allocator<char> >
00585   class trie : public PB_DS_BASE_C_DEC
00586   {
00587   private:
00588     typedef PB_DS_BASE_C_DEC base_type;
00589 
00590   public:
00591     // Element access traits type.
00592     typedef E_Access_Traits e_access_traits;
00593 
00594     trie() { }
00595 
00596     // Constructor taking some policy objects. r_e_access_traits will
00597     // be copied by the E_Access_Traits object of the container
00598     // object.
00599     trie(const e_access_traits& t)
00600     : base_type(t) { }
00601 
00602     // Constructor taking __iterators to a range of value_types. The
00603     // value_types between first_it and last_it will be inserted into
00604     // the container object.
00605     template<typename It>
00606     trie(It first, It last)
00607     { base_type::copy_from_range(first, last); }
00608 
00609     // Constructor taking __iterators to a range of value_types and
00610     // some policy objects. The value_types between first_it and
00611     // last_it will be inserted into the container object.
00612     template<typename It>
00613     trie(It first, It last, const e_access_traits& t)
00614     : base_type(t)
00615     { base_type::copy_from_range(first, last); }
00616 
00617     trie(const trie& other)
00618     : base_type((const base_type&)other) { }
00619 
00620     virtual
00621     ~trie() { }
00622 
00623     trie& 
00624     operator=(const trie& other)
00625     {
00626       if (this != &other)
00627     {
00628       trie tmp(other);
00629       swap(tmp);
00630     }
00631       return *this;
00632     }
00633 
00634     void
00635     swap(trie& other)
00636     { base_type::swap(other); }
00637   };
00638 
00639 #undef PB_DS_BASE_C_DEC
00640 #undef PB_DS_TRIE_NODE_AND_ITS_TRAITS
00641 
00642 
00643 #define PB_DS_BASE_C_DEC \
00644   container_base<Key, Mapped, list_update_tag, \
00645          typename __gnu_cxx::typelist::create2<Eq_Fn, Update_Policy>::type, Allocator>
00646 
00647   /// A list-update based associative container.
00648   template<typename Key,
00649        typename Mapped,
00650        class Eq_Fn = typename detail::default_eq_fn<Key>::type,
00651        class Update_Policy = detail::default_update_policy::type,
00652        class Allocator = std::allocator<char> >
00653   class list_update : public PB_DS_BASE_C_DEC
00654   {
00655   private:
00656     typedef PB_DS_BASE_C_DEC    base_type;
00657 
00658   public:
00659     typedef Eq_Fn       eq_fn;
00660     typedef Update_Policy   update_policy;
00661     typedef Allocator       allocator;
00662 
00663     list_update() { }
00664 
00665     // Constructor taking __iterators to a range of value_types. The
00666     // value_types between first_it and last_it will be inserted into
00667     // the container object.
00668     template<typename It>
00669     list_update(It first, It last)
00670     { base_type::copy_from_range(first, last); }
00671 
00672     list_update(const list_update& other)
00673     : base_type((const base_type&)other) { }
00674 
00675     virtual
00676     ~list_update() { }
00677 
00678     list_update& 
00679     operator=(const list_update& other)
00680     {
00681       if (this !=& other)
00682     {
00683       list_update tmp(other);
00684       swap(tmp);
00685     }
00686       return *this;
00687     }
00688 
00689     void
00690     swap(list_update& other)
00691     { base_type::swap(other); }
00692   };
00693 
00694 #undef PB_DS_BASE_C_DEC
00695 
00696   // @} group pbds
00697 } // namespace __gnu_pbds
00698 
00699 #endif