3 // Copyright (C) 2005, 2006, 2009, 2011 Free Software Foundation, Inc.
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
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
37 * @file rc_binomial_heap_.hpp
38 * Contains an implementation for rc_binomial_heap_.
42 * Redundant-counter binomial heap.
45 #include <ext/pb_ds/detail/cond_dealtor.hpp>
46 #include <ext/pb_ds/detail/type_utils.hpp>
47 #include <ext/pb_ds/detail/binomial_heap_base_/binomial_heap_base_.hpp>
48 #include <ext/pb_ds/detail/rc_binomial_heap_/rc.hpp>
49 #include <debug/debug.h>
55 #define PB_DS_CLASS_T_DEC \
56 template<typename Value_Type, class Cmp_Fn, class Allocator>
58 #define PB_DS_CLASS_C_DEC \
59 rc_binomial_heap_<Value_Type, Cmp_Fn, Allocator>
61 #define PB_DS_BASE_C_DEC \
62 binomial_heap_base_<Value_Type, Cmp_Fn, Allocator>
64 #define PB_DS_RC_C_DEC \
65 rc<typename PB_DS_BASE_C_DEC::node, Allocator>
68 * class description = "8y|\|0|\/|i41 h34p 74813">
70 template<typename Value_Type
, class Cmp_Fn
, class Allocator
>
71 class rc_binomial_heap_
: public PB_DS_BASE_C_DEC
75 typedef PB_DS_BASE_C_DEC base_type
;
77 typedef typename
base_type::node_pointer node_pointer
;
79 typedef typename
base_type::const_node_pointer const_node_pointer
;
81 typedef PB_DS_RC_C_DEC rc_t
;
85 typedef typename
Allocator::size_type size_type
;
87 typedef typename
Allocator::difference_type difference_type
;
89 typedef Value_Type value_type
;
91 typedef typename
base_type::pointer pointer
;
93 typedef typename
base_type::const_pointer const_pointer
;
95 typedef typename
base_type::reference reference
;
97 typedef typename
base_type::const_reference const_reference
;
99 typedef typename
base_type::const_point_iterator const_point_iterator
;
101 typedef typename
base_type::point_iterator point_iterator
;
103 typedef typename
base_type::const_iterator const_iterator
;
105 typedef typename
base_type::iterator iterator
;
107 typedef typename
base_type::cmp_fn cmp_fn
;
109 typedef typename
base_type::allocator_type allocator_type
;
115 rc_binomial_heap_(const Cmp_Fn
& r_cmp_fn
);
117 rc_binomial_heap_(const PB_DS_CLASS_C_DEC
& other
);
119 ~rc_binomial_heap_();
122 swap(PB_DS_CLASS_C_DEC
& other
);
124 inline point_iterator
125 push(const_reference r_val
);
128 modify(point_iterator it
, const_reference r_new_val
);
134 erase(point_iterator it
);
139 template<typename Pred
>
143 template<typename Pred
>
145 split(Pred pred
, PB_DS_CLASS_C_DEC
& other
);
148 join(PB_DS_CLASS_C_DEC
& other
);
150 #ifdef _GLIBCXX_DEBUG
152 assert_valid(const char* file
, int line
) const;
155 #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
163 link_with_next_sibling(node_pointer p_nd
);
169 make_binomial_heap();
171 #ifdef _GLIBCXX_DEBUG
172 static const_node_pointer
173 next_2_pointer(const_node_pointer p_nd
);
175 static const_node_pointer
176 next_after_0_pointer(const_node_pointer p_nd
);
183 #include <ext/pb_ds/detail/rc_binomial_heap_/constructors_destructor_fn_imps.hpp>
184 #include <ext/pb_ds/detail/rc_binomial_heap_/debug_fn_imps.hpp>
185 #include <ext/pb_ds/detail/rc_binomial_heap_/erase_fn_imps.hpp>
186 #include <ext/pb_ds/detail/rc_binomial_heap_/trace_fn_imps.hpp>
187 #include <ext/pb_ds/detail/rc_binomial_heap_/insert_fn_imps.hpp>
188 #include <ext/pb_ds/detail/rc_binomial_heap_/split_join_fn_imps.hpp>
190 #undef PB_DS_CLASS_C_DEC
191 #undef PB_DS_CLASS_T_DEC
192 #undef PB_DS_BASE_C_DEC
193 #undef PB_DS_RC_C_DEC
194 } // namespace detail
195 } // namespace __gnu_pbds