3 // Copyright (C) 2005, 2006 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 2, 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 // You should have received a copy of the GNU General Public License
17 // along with this library; see the file COPYING. If not, write to
18 // the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19 // MA 02111-1307, USA.
21 // As a special exception, you may use this file as part of a free
22 // software library without restriction. Specifically, if other files
23 // instantiate templates or use macros or inline functions from this
24 // file, or you compile this file and link it with other files to
25 // produce an executable, this file does not by itself cause the
26 // resulting executable to be covered by the GNU General Public
27 // License. This exception does not however invalidate any other
28 // reasons why the executable file might be covered by the GNU General
31 // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
33 // Permission to use, copy, modify, sell, and distribute this software
34 // is hereby granted without fee, provided that the above copyright
35 // notice appears in all copies, and that both that copyright notice
36 // and this permission notice appear in supporting documentation. None
37 // of the above authors, nor IBM Haifa Research Laboratories, make any
38 // representation about the suitability of this software for any
39 // purpose. It is provided "as is" without express or implied
44 * Contains a redundant (binary counter).
55 #define PB_DS_CLASS_T_DEC \
56 template<typename Node, class Allocator>
58 #define PB_DS_CLASS_C_DEC \
61 template<typename Node
, class Allocator
>
65 typedef Allocator allocator
;
67 typedef typename
allocator::size_type size_type
;
72 typename
allocator::template rebind
<
77 typename
allocator::template rebind
<
78 node_pointer
>::other::pointer
82 typename
allocator::template rebind
<
83 node_pointer
>::other::const_pointer
88 max_entries
= sizeof(size_type
) << 3
92 typedef node_pointer entry
;
94 typedef const_entry_pointer const_iterator
;
99 rc(const PB_DS_CLASS_C_DEC
& other
);
102 swap(PB_DS_CLASS_C_DEC
& other
);
128 #ifdef _GLIBCXX_DEBUG
130 assert_valid() const;
133 #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
139 node_pointer m_a_entries
[max_entries
];
141 size_type m_over_top
;
147 { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
151 rc(const PB_DS_CLASS_C_DEC
& other
) : m_over_top(0)
152 { _GLIBCXX_DEBUG_ONLY(assert_valid();) }
157 swap(PB_DS_CLASS_C_DEC
& other
)
159 _GLIBCXX_DEBUG_ONLY(assert_valid();)
160 _GLIBCXX_DEBUG_ONLY(other
.assert_valid();)
162 const size_type over_top
= std::max(m_over_top
, other
.m_over_top
);
164 for (size_type i
= 0; i
< over_top
; ++i
)
165 std::swap(m_a_entries
[i
], other
.m_a_entries
[i
]);
167 std::swap(m_over_top
, other
.m_over_top
);
168 _GLIBCXX_DEBUG_ONLY(assert_valid();)
169 _GLIBCXX_DEBUG_ONLY(other
.assert_valid();)
177 _GLIBCXX_DEBUG_ONLY(assert_valid();)
178 _GLIBCXX_DEBUG_ASSERT(m_over_top
< max_entries
);
179 m_a_entries
[m_over_top
++] = p_nd
;
180 _GLIBCXX_DEBUG_ONLY(assert_valid();)
188 _GLIBCXX_DEBUG_ONLY(assert_valid();)
189 _GLIBCXX_DEBUG_ASSERT(!empty());
191 _GLIBCXX_DEBUG_ONLY(assert_valid();)
195 inline typename
PB_DS_CLASS_C_DEC::node_pointer
199 _GLIBCXX_DEBUG_ONLY(assert_valid();)
200 _GLIBCXX_DEBUG_ASSERT(!empty());
201 return *(m_a_entries
+ m_over_top
- 1);
209 _GLIBCXX_DEBUG_ONLY(assert_valid();)
210 return m_over_top
== 0;
214 inline typename
PB_DS_CLASS_C_DEC::size_type
217 { return m_over_top
; }
224 _GLIBCXX_DEBUG_ONLY(assert_valid();)
226 _GLIBCXX_DEBUG_ONLY(assert_valid();)
230 const typename
PB_DS_CLASS_C_DEC::const_iterator
233 { return& m_a_entries
[0]; }
236 const typename
PB_DS_CLASS_C_DEC::const_iterator
239 { return& m_a_entries
[m_over_top
]; }
241 #ifdef _GLIBCXX_DEBUG
246 { _GLIBCXX_DEBUG_ASSERT(m_over_top
< max_entries
); }
249 #ifdef PB_DS_RC_BINOMIAL_HEAP_TRACE_
255 std::cout
<< "rc" << std::endl
;
256 for (size_type i
= 0; i
< m_over_top
; ++i
)
257 std::cerr
<< m_a_entries
[i
] << std::endl
;
258 std::cout
<< std::endl
;
262 #undef PB_DS_CLASS_T_DEC
263 #undef PB_DS_CLASS_C_DEC
265 } // namespace detail
266 } // namespace __gnu_pbds