debug_fn_imps.hpp revision 1.1.1.11
1213904Sandreast// -*- C++ -*-
2213904Sandreast
3213904Sandreast// Copyright (C) 2005-2022 Free Software Foundation, Inc.
4213904Sandreast//
5213904Sandreast// This file is part of the GNU ISO C++ Library.  This library is free
6213904Sandreast// software; you can redistribute it and/or modify it under the terms
7213904Sandreast// of the GNU General Public License as published by the Free Software
8213904Sandreast// Foundation; either version 3, or (at your option) any later
9213904Sandreast// version.
10213904Sandreast
11213904Sandreast// This library is distributed in the hope that it will be useful, but
12213904Sandreast// WITHOUT ANY WARRANTY; without even the implied warranty of
13213904Sandreast// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14213904Sandreast// General Public License for more details.
15213904Sandreast
16213904Sandreast// Under Section 7 of GPL version 3, you are granted additional
17213904Sandreast// permissions described in the GCC Runtime Library Exception, version
18213904Sandreast// 3.1, as published by the Free Software Foundation.
19213904Sandreast
20213904Sandreast// You should have received a copy of the GNU General Public License and
21213904Sandreast// a copy of the GCC Runtime Library Exception along with this program;
22213904Sandreast// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
23213904Sandreast// <http://www.gnu.org/licenses/>.
24213904Sandreast
25213904Sandreast// Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL.
26213904Sandreast
27213904Sandreast// Permission to use, copy, modify, sell, and distribute this software
28213904Sandreast// is hereby granted without fee, provided that the above copyright
29213904Sandreast// notice appears in all copies, and that both that copyright notice
30213904Sandreast// and this permission notice appear in supporting documentation. None
31213904Sandreast// of the above authors, nor IBM Haifa Research Laboratories, make any
32213904Sandreast// representation about the suitability of this software for any
33213904Sandreast// purpose. It is provided "as is" without express or implied
34213904Sandreast// warranty.
35213904Sandreast
36213904Sandreast/**
37213904Sandreast * @file binary_heap_/debug_fn_imps.hpp
38213904Sandreast * Contains an implementation class for a binary_heap.
39213904Sandreast */
40213904Sandreast
41213904Sandreast#ifdef PB_DS_CLASS_C_DEC
42213904Sandreast
43213904Sandreast#ifdef _GLIBCXX_DEBUG
44213904Sandreast
45213904SandreastPB_DS_CLASS_T_DEC
46213904Sandreastvoid
47213904SandreastPB_DS_CLASS_C_DEC::
48213904Sandreastassert_valid(const char* __file, int __line) const
49213904Sandreast{
50213904Sandreast#ifdef PB_DS_REGRESSION
51213904Sandreast  s_entry_allocator.check_allocated(m_a_entries, m_actual_size);
52222458Snwhitehorn#endif
53213904Sandreast
54213904Sandreast  resize_policy::assert_valid(__file, __line);
55213904Sandreast  PB_DS_DEBUG_VERIFY(m_size <= m_actual_size);
56213904Sandreast  for (size_type i = 0; i < m_size; ++i)
57213904Sandreast    {
58213904Sandreast#ifdef PB_DS_REGRESSION
59213904Sandreast      s_value_allocator.check_allocated(m_a_entries[i], 1);
60213904Sandreast#endif
61222458Snwhitehorn
62222458Snwhitehorn      if (left_child(i) < m_size)
63222458Snwhitehorn	PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[left_child(i)]));
64222458Snwhitehorn
65222458Snwhitehorn      PB_DS_DEBUG_VERIFY(parent(left_child(i)) == i);
66222458Snwhitehorn
67222458Snwhitehorn      if (right_child(i) < m_size)
68213904Sandreast	PB_DS_DEBUG_VERIFY(!entry_cmp::operator()(m_a_entries[i], m_a_entries[right_child(i)]));
69222458Snwhitehorn
70213904Sandreast      PB_DS_DEBUG_VERIFY(parent(right_child(i)) == i);
71213904Sandreast    }
72213904Sandreast}
73213904Sandreast
74213904Sandreast#endif
75213904Sandreast#endif
76213904Sandreast