]>
Commit | Line | Data |
---|---|---|
4569a895 AT |
1 | // -*- C++ -*- |
2 | ||
83ffe9cd | 3 | // Copyright (C) 2005-2023 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_/point_const_iterator.hpp |
4569a895 | 38 | * Contains an iterator class returned by the table's const find and insert |
a345e45d | 39 | * methods. |
4569a895 AT |
40 | */ |
41 | ||
42 | #ifndef PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP | |
43 | #define PB_DS_BINARY_HEAP_CONST_FIND_ITERATOR_HPP | |
44 | ||
45 | #include <ext/pb_ds/tag_and_trait.hpp> | |
47bea7b8 | 46 | #include <debug/debug.h> |
4569a895 | 47 | |
5e11f978 | 48 | namespace __gnu_pbds |
4569a895 AT |
49 | { |
50 | namespace detail | |
51 | { | |
30a96b3b | 52 | /// Const point-type iterator. |
beb5d0f4 | 53 | template<typename Value_Type, typename Entry, bool Simple, |
a345e45d BK |
54 | typename _Alloc> |
55 | class binary_heap_point_const_iterator_ | |
4569a895 | 56 | { |
4569a895 | 57 | protected: |
ec541f1b | 58 | typedef typename rebind_traits<_Alloc, Entry>::pointer entry_pointer; |
4569a895 AT |
59 | |
60 | public: | |
30a96b3b | 61 | /// Category. |
4569a895 AT |
62 | typedef trivial_iterator_tag iterator_category; |
63 | ||
30a96b3b | 64 | /// Difference type. |
4569a895 AT |
65 | typedef trivial_iterator_difference_type difference_type; |
66 | ||
30a96b3b | 67 | /// Iterator's value type. |
4569a895 AT |
68 | typedef Value_Type value_type; |
69 | ||
30a96b3b | 70 | /// Iterator's pointer type. |
ec541f1b | 71 | typedef typename rebind_traits<_Alloc, value_type>::pointer pointer; |
4569a895 | 72 | |
30a96b3b | 73 | /// Iterator's const pointer type. |
ec541f1b JW |
74 | typedef typename rebind_traits<_Alloc, value_type>::const_pointer |
75 | const_pointer; | |
4569a895 | 76 | |
30a96b3b | 77 | /// Iterator's reference type. |
ec541f1b JW |
78 | typedef typename rebind_traits<_Alloc, value_type>::reference |
79 | reference; | |
4569a895 | 80 | |
30a96b3b | 81 | /// Iterator's const reference type. |
ec541f1b JW |
82 | typedef typename rebind_traits<_Alloc, value_type>::const_reference |
83 | const_reference; | |
4569a895 | 84 | |
4569a895 | 85 | inline |
a345e45d | 86 | binary_heap_point_const_iterator_(entry_pointer p_e) : m_p_e(p_e) |
4569a895 AT |
87 | { } |
88 | ||
30a96b3b | 89 | /// Default constructor. |
4569a895 | 90 | inline |
a345e45d | 91 | binary_heap_point_const_iterator_() : m_p_e(0) { } |
4569a895 | 92 | |
30a96b3b | 93 | /// Copy constructor. |
4569a895 | 94 | inline |
a345e45d | 95 | binary_heap_point_const_iterator_(const binary_heap_point_const_iterator_& other) |
47bea7b8 | 96 | : m_p_e(other.m_p_e) |
4569a895 AT |
97 | { } |
98 | ||
30a96b3b | 99 | /// Access. |
4569a895 AT |
100 | inline const_pointer |
101 | operator->() const | |
102 | { | |
8fc81078 | 103 | _GLIBCXX_DEBUG_ASSERT(m_p_e != 0); |
beb5d0f4 | 104 | return to_ptr(integral_constant<int, Simple>()); |
4569a895 AT |
105 | } |
106 | ||
30a96b3b | 107 | /// Access. |
4569a895 AT |
108 | inline const_reference |
109 | operator*() const | |
110 | { | |
8fc81078 | 111 | _GLIBCXX_DEBUG_ASSERT(m_p_e != 0); |
beb5d0f4 | 112 | return *to_ptr(integral_constant<int, Simple>()); |
4569a895 AT |
113 | } |
114 | ||
30a96b3b | 115 | /// Compares content to a different iterator object. |
4569a895 | 116 | inline bool |
a345e45d | 117 | operator==(const binary_heap_point_const_iterator_& other) const |
47bea7b8 | 118 | { return m_p_e == other.m_p_e; } |
4569a895 | 119 | |
30a96b3b | 120 | /// Compares content (negatively) to a different iterator object. |
4569a895 | 121 | inline bool |
a345e45d | 122 | operator!=(const binary_heap_point_const_iterator_& other) const |
47bea7b8 | 123 | { return m_p_e != other.m_p_e; } |
4569a895 AT |
124 | |
125 | private: | |
126 | inline const_pointer | |
127 | to_ptr(true_type) const | |
47bea7b8 | 128 | { return m_p_e; } |
4569a895 AT |
129 | |
130 | inline const_pointer | |
131 | to_ptr(false_type) const | |
47bea7b8 | 132 | { return *m_p_e; } |
4569a895 AT |
133 | |
134 | public: | |
135 | entry_pointer m_p_e; | |
136 | }; | |
4569a895 | 137 | } // namespace detail |
5e11f978 | 138 | } // namespace __gnu_pbds |
4569a895 | 139 | |
47bea7b8 | 140 | #endif |