libstdc++
pat_trie_/traits.hpp
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 // Copyright (C) 2005, 2006, 2009, 2011 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 pat_trie_/traits.hpp
00038  * Contains an implementation class for pat_trie_.
00039  */
00040 
00041 #ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP
00042 #define PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP
00043 
00044 #include <ext/pb_ds/detail/pat_trie_/pat_trie_base.hpp>
00045 #include <ext/pb_ds/detail/pat_trie_/synth_access_traits.hpp>
00046 
00047 namespace __gnu_pbds
00048 {
00049   namespace detail
00050   {
00051     /// Specialization.
00052     /// @ingroup traits
00053     template<typename Key,
00054          typename Mapped,
00055          typename _ATraits,
00056          template<typename Node_CItr,
00057               typename Node_Itr,
00058               typename Cmp_Fn_,
00059               typename _Alloc_>
00060          class Node_Update,
00061          typename _Alloc>
00062     struct trie_traits<Key, Mapped, _ATraits, Node_Update, pat_trie_tag, _Alloc>
00063     {
00064     private:
00065       typedef pat_trie_base                     base_type;
00066       typedef types_traits<Key, Mapped, _Alloc, false>      type_traits;
00067 
00068     public:
00069       typedef typename trie_node_metadata_dispatch<Key, Mapped, _ATraits, Node_Update, _Alloc>::type metadata_type;
00070       typedef base_type::_Metadata<metadata_type, _Alloc>       metadata;
00071       typedef _ATraits                              access_traits;
00072 
00073       /// Type for synthesized traits.
00074       typedef __gnu_pbds::detail::synth_access_traits<type_traits, false, access_traits>   synth_access_traits;
00075 
00076       typedef base_type::_Node_base<synth_access_traits, metadata>      node;
00077       typedef base_type::_Head<synth_access_traits, metadata>           head;
00078       typedef base_type::_Leaf<synth_access_traits, metadata>           leaf;
00079       typedef base_type::_Inode<synth_access_traits, metadata>      inode;
00080 
00081       typedef base_type::_Iter<node, leaf, head, inode, true>           iterator;
00082       typedef base_type::_CIter<node, leaf, head, inode, true>      const_iterator;
00083       typedef base_type::_Iter<node, leaf, head, inode, false>      reverse_iterator;
00084       typedef base_type::_CIter<node, leaf, head, inode, false>     const_reverse_iterator;
00085 
00086       /// This is an iterator to an iterator: it iterates over nodes,
00087       /// and de-referencing it returns one of the tree's iterators.
00088       typedef base_type::_Node_citer<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_const_iterator;
00089 
00090       typedef base_type::_Node_iter<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_iterator;
00091 
00092       /// Type for node update.
00093       typedef Node_Update<node_const_iterator, node_iterator, _ATraits, _Alloc>         node_update;
00094 
00095       typedef null_node_update<node_const_iterator, node_iterator, _ATraits, _Alloc>*       null_node_update_pointer;
00096     };
00097 
00098 
00099     /// Specialization.
00100     /// @ingroup traits
00101     template<typename Key,
00102          typename _ATraits,
00103          template<typename Node_CItr,
00104               typename Node_Itr,
00105               typename Cmp_Fn_,
00106               typename _Alloc_>
00107          class Node_Update,
00108          typename _Alloc>
00109     struct trie_traits<Key, null_type, _ATraits, Node_Update, pat_trie_tag, _Alloc>
00110     {
00111     private:
00112       typedef pat_trie_base                 base_type;
00113       typedef types_traits<Key, null_type, _Alloc, false>   type_traits;
00114 
00115     public:
00116       typedef typename trie_node_metadata_dispatch<Key, null_type, _ATraits, Node_Update, _Alloc>::type metadata_type;
00117       typedef base_type::_Metadata<metadata_type, _Alloc>               metadata;
00118       typedef _ATraits                                      access_traits;
00119 
00120       /// Type for synthesized traits.
00121       typedef __gnu_pbds::detail::synth_access_traits<type_traits, true, access_traits> synth_access_traits;
00122 
00123       typedef base_type::_Node_base<synth_access_traits, metadata>      node;
00124       typedef base_type::_Head<synth_access_traits, metadata>           head;
00125       typedef base_type::_Leaf<synth_access_traits, metadata>           leaf;
00126       typedef base_type::_Inode<synth_access_traits, metadata>          inode;
00127 
00128       typedef base_type::_CIter<node, leaf, head, inode, true>      const_iterator;
00129       typedef const_iterator                            iterator;
00130       typedef base_type::_CIter<node, leaf, head, inode, false>         const_reverse_iterator;
00131       typedef const_reverse_iterator                        reverse_iterator;
00132 
00133       /// This is an iterator to an iterator: it iterates over nodes,
00134       /// and de-referencing it returns one of the tree's iterators.
00135       typedef base_type::_Node_citer<node, leaf, head, inode, const_iterator, iterator, _Alloc> node_const_iterator;
00136 
00137       typedef node_const_iterator                               node_iterator;
00138 
00139       /// Type for node update.
00140       typedef Node_Update<node_const_iterator, node_iterator, _ATraits, _Alloc>         node_update;
00141 
00142       typedef null_node_update<node_const_iterator, node_const_iterator, _ATraits, _Alloc>*     null_node_update_pointer;
00143     };
00144 
00145   } // namespace detail
00146 } // namespace __gnu_pbds
00147 
00148 #endif // #ifndef PB_DS_PAT_TRIE_NODE_AND_IT_TRAITS_HPP