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 / binomial_heap_base_ / binomial_heap_base_.hpp
blob1d66d1b14bcc4efad614fcb116a5daa54a272a0d
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 binomial_heap_base_.hpp
38 * Contains an implementation class for a base of binomial heaps.
41 #ifndef PB_DS_BINOMIAL_HEAP_BASE_HPP
42 #define PB_DS_BINOMIAL_HEAP_BASE_HPP
45 * Binomial heap base.
46 * Vuillemin J is the mastah.
47 * Modified from CLRS.
50 #include <debug/debug.h>
51 #include <ext/pb_ds/detail/cond_dealtor.hpp>
52 #include <ext/pb_ds/detail/type_utils.hpp>
53 #include <ext/pb_ds/detail/left_child_next_sibling_heap_/left_child_next_sibling_heap_.hpp>
54 #include <ext/pb_ds/detail/left_child_next_sibling_heap_/null_metadata.hpp>
56 namespace __gnu_pbds
58 namespace detail
61 #define PB_DS_CLASS_T_DEC \
62 template<typename Value_Type, class Cmp_Fn, class Allocator>
64 #define PB_DS_CLASS_C_DEC \
65 binomial_heap_base_<Value_Type, Cmp_Fn, Allocator>
67 #ifdef _GLIBCXX_DEBUG
68 #define PB_DS_BASE_C_DEC \
69 left_child_next_sibling_heap_<Value_Type, Cmp_Fn, \
70 typename Allocator::size_type, \
71 Allocator, false>
72 #else
73 #define PB_DS_BASE_C_DEC \
74 left_child_next_sibling_heap_<Value_Type, Cmp_Fn, \
75 typename Allocator::size_type, Allocator>
76 #endif
78 /**
79 * class description = "8y|\|0|\/|i41 h34p 74813">
80 **/
81 template<typename Value_Type, class Cmp_Fn, class Allocator>
82 class binomial_heap_base_ : public PB_DS_BASE_C_DEC
85 private:
86 typedef PB_DS_BASE_C_DEC base_type;
88 protected:
89 typedef typename base_type::node node;
91 typedef typename base_type::node_pointer node_pointer;
93 typedef typename base_type::const_node_pointer const_node_pointer;
95 public:
97 typedef typename Allocator::size_type size_type;
99 typedef typename Allocator::difference_type difference_type;
101 typedef Value_Type value_type;
103 typedef
104 typename Allocator::template rebind<
105 value_type>::other::pointer
106 pointer;
108 typedef
109 typename Allocator::template rebind<
110 value_type>::other::const_pointer
111 const_pointer;
113 typedef
114 typename Allocator::template rebind<
115 value_type>::other::reference
116 reference;
118 typedef
119 typename Allocator::template rebind<
120 value_type>::other::const_reference
121 const_reference;
123 typedef
124 typename PB_DS_BASE_C_DEC::const_point_iterator
125 const_point_iterator;
127 typedef typename PB_DS_BASE_C_DEC::point_iterator point_iterator;
129 typedef typename PB_DS_BASE_C_DEC::const_iterator const_iterator;
131 typedef typename PB_DS_BASE_C_DEC::iterator iterator;
133 typedef Cmp_Fn cmp_fn;
135 typedef Allocator allocator_type;
137 public:
139 inline point_iterator
140 push(const_reference r_val);
142 void
143 modify(point_iterator it, const_reference r_new_val);
145 inline const_reference
146 top() const;
148 void
149 pop();
151 void
152 erase(point_iterator it);
154 inline void
155 clear();
157 template<typename Pred>
158 size_type
159 erase_if(Pred pred);
161 template<typename Pred>
162 void
163 split(Pred pred, PB_DS_CLASS_C_DEC& other);
165 void
166 join(PB_DS_CLASS_C_DEC& other);
168 protected:
170 binomial_heap_base_();
172 binomial_heap_base_(const Cmp_Fn& r_cmp_fn);
174 binomial_heap_base_(const PB_DS_CLASS_C_DEC& other);
176 void
177 swap(PB_DS_CLASS_C_DEC& other);
179 ~binomial_heap_base_();
181 template<typename It>
182 void
183 copy_from_range(It first_it, It last_it);
185 inline void
186 find_max();
188 #ifdef _GLIBCXX_DEBUG
189 void
190 assert_valid(bool strictly_binomial) const;
192 void
193 assert_max() const;
194 #endif
196 private:
198 inline node_pointer
199 fix(node_pointer p_nd) const;
201 inline void
202 insert_node(node_pointer p_nd);
204 inline void
205 remove_parentless_node(node_pointer p_nd);
207 inline node_pointer
208 join(node_pointer p_lhs, node_pointer p_rhs) const;
210 #ifdef _GLIBCXX_DEBUG
211 void
212 assert_node_consistent(const_node_pointer, bool, bool) const;
213 #endif
215 protected:
216 node_pointer m_p_max;
219 #include <ext/pb_ds/detail/binomial_heap_base_/constructors_destructor_fn_imps.hpp>
220 #include <ext/pb_ds/detail/binomial_heap_base_/debug_fn_imps.hpp>
221 #include <ext/pb_ds/detail/binomial_heap_base_/find_fn_imps.hpp>
222 #include <ext/pb_ds/detail/binomial_heap_base_/insert_fn_imps.hpp>
223 #include <ext/pb_ds/detail/binomial_heap_base_/erase_fn_imps.hpp>
224 #include <ext/pb_ds/detail/binomial_heap_base_/split_join_fn_imps.hpp>
226 #undef PB_DS_CLASS_C_DEC
227 #undef PB_DS_CLASS_T_DEC
228 #undef PB_DS_BASE_C_DEC
231 } // namespace detail
232 } // namespace __gnu_pbds
234 #endif