GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / toolchains / hndtools-arm-linux-2.6.36-uclibc-4.5.3 / arm-brcm-linux-uclibcgnueabi / include / c++ / 4.5.3 / ext / pb_ds / detail / pat_trie_ / synth_e_access_traits.hpp
blobabf5f1185237dd32e39c57c97e6cf86c935fad7f
1 // -*- C++ -*-
3 // Copyright (C) 2005, 2006, 2009 Free Software Foundation, Inc.
4 //
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the terms
7 // of the GNU General Public License as published by the Free Software
8 // Foundation; either version 3, or (at your option) any later
9 // version.
11 // This library is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // General Public License for more details.
16 // Under Section 7 of GPL version 3, you are granted additional
17 // permissions described in the GCC Runtime Library Exception, version
18 // 3.1, as published by the Free Software Foundation.
20 // You should have received a copy of the GNU General Public License and
21 // a copy of the GCC Runtime Library Exception along with this program;
22 // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 // <http://www.gnu.org/licenses/>.
25 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
27 // Permission to use, copy, modify, sell, and distribute this software
28 // is hereby granted without fee, provided that the above copyright
29 // notice appears in all copies, and that both that copyright notice
30 // and this permission notice appear in supporting documentation. None
31 // of the above authors, nor IBM Haifa Research Laboratories, make any
32 // representation about the suitability of this software for any
33 // purpose. It is provided "as is" without express or implied
34 // warranty.
36 /**
37 * @file synth_e_access_traits.hpp
38 * Contains an implementation class for a patricia tree.
41 #ifndef PB_DS_SYNTH_E_ACCESS_TRAITS_HPP
42 #define PB_DS_SYNTH_E_ACCESS_TRAITS_HPP
44 #include <ext/pb_ds/detail/type_utils.hpp>
46 namespace __gnu_pbds
48 namespace detail
51 #define PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC \
52 template<typename Type_Traits, bool Set, class E_Access_Traits>
54 #define PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC \
55 synth_e_access_traits< \
56 Type_Traits, \
57 Set, \
58 E_Access_Traits>
60 template<typename Type_Traits, bool Set, class E_Access_Traits>
61 struct synth_e_access_traits : public E_Access_Traits
64 private:
65 typedef E_Access_Traits base_type;
67 typedef Type_Traits type_traits;
69 typedef typename type_traits::const_key_reference const_key_reference;
71 typedef typename type_traits::const_reference const_reference;
73 public:
74 synth_e_access_traits();
76 synth_e_access_traits(const E_Access_Traits& r_traits);
78 inline bool
79 equal_prefixes(typename base_type::const_iterator b_l, typename base_type::const_iterator e_l, typename base_type::const_iterator b_r, typename base_type::const_iterator e_r, bool compare_after = true) const;
81 bool
82 equal_keys(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const;
84 bool
85 cmp_prefixes(typename base_type::const_iterator b_l, typename base_type::const_iterator e_l, typename base_type::const_iterator b_r, typename base_type::const_iterator e_r, bool compare_after = false) const;
87 bool
88 cmp_keys(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const;
90 inline static const_key_reference
91 extract_key(const_reference r_val);
93 #ifdef _GLIBCXX_DEBUG
94 bool
95 operator()(const_key_reference r_lhs, const_key_reference r_rhs);
96 #endif
98 private:
99 inline static const_key_reference
100 extract_key(const_reference r_val, true_type);
102 inline static const_key_reference
103 extract_key(const_reference r_val, false_type);
105 private:
106 static integral_constant<int,Set> s_set_ind;
109 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
110 integral_constant<int,Set>
111 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::s_set_ind;
113 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
114 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
115 synth_e_access_traits()
118 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
119 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
120 synth_e_access_traits(const E_Access_Traits& r_traits) :
121 E_Access_Traits(r_traits)
124 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
125 inline bool
126 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
127 equal_prefixes(typename base_type::const_iterator b_l, typename base_type::const_iterator e_l, typename base_type::const_iterator b_r, typename base_type::const_iterator e_r, bool compare_after /*= false */) const
129 while (b_l != e_l)
131 if (b_r == e_r)
132 return (false);
133 if (base_type::e_pos(*b_l) != base_type::e_pos(*b_r))
134 return (false);
135 ++b_l;
136 ++b_r;
138 return (!compare_after || b_r == e_r);
141 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
142 bool
143 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
144 equal_keys(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const
146 return (equal_prefixes(base_type::begin(r_lhs_key),
147 base_type::end(r_lhs_key),
148 base_type::begin(r_rhs_key),
149 base_type::end(r_rhs_key),
150 true));
153 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
154 bool
155 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
156 cmp_prefixes(typename base_type::const_iterator b_l, typename base_type::const_iterator e_l, typename base_type::const_iterator b_r, typename base_type::const_iterator e_r, bool compare_after /* = false*/) const
158 while (b_l != e_l)
160 if (b_r == e_r)
161 return (false);
162 const typename base_type::size_type l_pos =
163 base_type::e_pos(*b_l);
164 const typename base_type::size_type r_pos =
165 base_type::e_pos(*b_r);
166 if (l_pos != r_pos)
167 return (l_pos < r_pos);
168 ++b_l;
169 ++b_r;
172 if (!compare_after)
173 return (false);
174 return (b_r != e_r);
177 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
178 bool
179 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
180 cmp_keys(const_key_reference r_lhs_key, const_key_reference r_rhs_key) const
182 return (cmp_prefixes(base_type::begin(r_lhs_key),
183 base_type::end(r_lhs_key),
184 base_type::begin(r_rhs_key),
185 base_type::end(r_rhs_key),
186 true));
189 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
190 inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::const_key_reference
191 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
192 extract_key(const_reference r_val)
194 return (extract_key(r_val, s_set_ind));
197 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
198 inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::const_key_reference
199 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
200 extract_key(const_reference r_val, true_type)
202 return (r_val);
205 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
206 inline typename PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::const_key_reference
207 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
208 extract_key(const_reference r_val, false_type)
210 return (r_val.first);
213 #ifdef _GLIBCXX_DEBUG
214 PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
215 bool
216 PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC::
217 operator()(const_key_reference r_lhs, const_key_reference r_rhs)
219 return (cmp_keys(r_lhs, r_rhs));
221 #endif
223 #undef PB_DS_SYNTH_E_ACCESS_TRAITS_T_DEC
224 #undef PB_DS_SYNTH_E_ACCESS_TRAITS_C_DEC
226 } // namespace detail
227 } // namespace __gnu_pbds
229 #endif