]>
Commit | Line | Data |
---|---|---|
4569a895 AT |
1 | // -*- C++ -*- |
2 | ||
99dee823 | 3 | // Copyright (C) 2005-2021 Free Software Foundation, Inc. |
4569a895 AT |
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 | |
748086b7 | 8 | // Foundation; either version 3, or (at your option) any later |
4569a895 AT |
9 | // version. |
10 | ||
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. | |
15 | ||
748086b7 JJ |
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. | |
4569a895 | 19 | |
748086b7 JJ |
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/>. | |
4569a895 AT |
24 | |
25 | // Copyright (C) 2004 Ami Tavory and Vladimir Dreizin, IBM-HRL. | |
26 | ||
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. | |
35 | ||
36 | /** | |
a345e45d | 37 | * @file binary_heap_/const_iterator.hpp |
4569a895 AT |
38 | * Contains an iterator class returned by the table's const find and insert |
39 | * methods. | |
40 | */ | |
41 | ||
42 | #ifndef PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP | |
43 | #define PB_DS_BINARY_HEAP_CONST_ITERATOR_HPP | |
44 | ||
a345e45d | 45 | #include <ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp> |
47bea7b8 | 46 | #include <debug/debug.h> |
4569a895 | 47 | |
5e11f978 | 48 | namespace __gnu_pbds |
4569a895 AT |
49 | { |
50 | namespace detail | |
51 | { | |
a345e45d BK |
52 | #define PB_DS_BIN_HEAP_CIT_BASE \ |
53 | binary_heap_point_const_iterator_<Value_Type, Entry, Simple, _Alloc> | |
4569a895 | 54 | |
a345e45d | 55 | /// Const point-type iterator. |
4569a895 AT |
56 | template<typename Value_Type, |
57 | typename Entry, | |
58 | bool Simple, | |
a345e45d BK |
59 | typename _Alloc> |
60 | class binary_heap_const_iterator_ : public PB_DS_BIN_HEAP_CIT_BASE | |
4569a895 | 61 | { |
4569a895 | 62 | private: |
a345e45d BK |
63 | typedef PB_DS_BIN_HEAP_CIT_BASE base_type; |
64 | typedef typename base_type::entry_pointer entry_pointer; | |
4569a895 AT |
65 | |
66 | public: | |
30a96b3b | 67 | /// Category. |
a345e45d | 68 | typedef std::forward_iterator_tag iterator_category; |
4569a895 | 69 | |
30a96b3b | 70 | /// Difference type. |
a345e45d | 71 | typedef typename _Alloc::difference_type difference_type; |
4569a895 | 72 | |
30a96b3b | 73 | /// Iterator's value type. |
a345e45d | 74 | typedef typename base_type::value_type value_type; |
4569a895 | 75 | |
30a96b3b | 76 | /// Iterator's pointer type. |
a345e45d | 77 | typedef typename base_type::pointer pointer; |
4569a895 | 78 | |
30a96b3b | 79 | /// Iterator's const pointer type. |
a345e45d | 80 | typedef typename base_type::const_pointer const_pointer; |
4569a895 | 81 | |
30a96b3b | 82 | /// Iterator's reference type. |
a345e45d | 83 | typedef typename base_type::reference reference; |
4569a895 | 84 | |
30a96b3b | 85 | /// Iterator's const reference type. |
a345e45d | 86 | typedef typename base_type::const_reference const_reference; |
4569a895 AT |
87 | |
88 | inline | |
89 | binary_heap_const_iterator_(entry_pointer p_e) : base_type(p_e) | |
90 | { } | |
91 | ||
30a96b3b | 92 | /// Default constructor. |
4569a895 AT |
93 | inline |
94 | binary_heap_const_iterator_() | |
95 | { } | |
96 | ||
30a96b3b | 97 | /// Copy constructor. |
4569a895 | 98 | inline |
a345e45d BK |
99 | binary_heap_const_iterator_(const binary_heap_const_iterator_& other) |
100 | : base_type(other) | |
4569a895 AT |
101 | { } |
102 | ||
30a96b3b | 103 | /// Compares content to a different iterator object. |
4569a895 | 104 | inline bool |
a345e45d BK |
105 | operator==(const binary_heap_const_iterator_& other) const |
106 | { return base_type::m_p_e == other.m_p_e; } | |
4569a895 | 107 | |
30a96b3b | 108 | /// Compares content (negatively) to a different iterator object. |
4569a895 | 109 | inline bool |
a345e45d BK |
110 | operator!=(const binary_heap_const_iterator_& other) const |
111 | { return base_type::m_p_e != other.m_p_e; } | |
4569a895 | 112 | |
a345e45d | 113 | inline binary_heap_const_iterator_& |
4569a895 AT |
114 | operator++() |
115 | { | |
8fc81078 | 116 | _GLIBCXX_DEBUG_ASSERT(base_type::m_p_e != 0); |
4569a895 | 117 | inc(); |
47bea7b8 | 118 | return *this; |
4569a895 AT |
119 | } |
120 | ||
a345e45d | 121 | inline binary_heap_const_iterator_ |
4569a895 AT |
122 | operator++(int) |
123 | { | |
a345e45d | 124 | binary_heap_const_iterator_ ret_it(base_type::m_p_e); |
4569a895 | 125 | operator++(); |
47bea7b8 | 126 | return ret_it; |
4569a895 AT |
127 | } |
128 | ||
129 | private: | |
130 | void | |
131 | inc() | |
47bea7b8 | 132 | { ++base_type::m_p_e; } |
4569a895 AT |
133 | }; |
134 | ||
a345e45d | 135 | #undef PB_DS_BIN_HEAP_CIT_BASE |
4569a895 | 136 | } // namespace detail |
5e11f978 | 137 | } // namespace __gnu_pbds |
4569a895 | 138 | |
47bea7b8 | 139 | #endif |