]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/include/ext/pb_ds/detail/binary_heap_/point_const_iterator.hpp
Update Copyright years for files modified in 2011 and/or 2012.
[thirdparty/gcc.git] / libstdc++-v3 / include / ext / pb_ds / detail / binary_heap_ / point_const_iterator.hpp
CommitLineData
36fed23c 1// -*- C++ -*-
2
71e45bc2 3// Copyright (C) 2005, 2006, 2009, 2010, 2011 Free Software Foundation, Inc.
36fed23c 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
6bc9506f 8// Foundation; either version 3, or (at your option) any later
36fed23c 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
6bc9506f 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.
36fed23c 19
6bc9506f 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/>.
36fed23c 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/**
4f4a327e 37 * @file binary_heap_/point_const_iterator.hpp
36fed23c 38 * Contains an iterator class returned by the table's const find and insert
4f4a327e 39 * methods.
36fed23c 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>
2b31bec4 46#include <debug/debug.h>
36fed23c 47
b34535d7 48namespace __gnu_pbds
36fed23c 49{
50 namespace detail
51 {
3f2eba6f 52 /// Const point-type iterator.
76918d89 53 template<typename Value_Type, typename Entry, bool Simple,
4f4a327e 54 typename _Alloc>
55 class binary_heap_point_const_iterator_
36fed23c 56 {
36fed23c 57 protected:
4f4a327e 58 typedef typename _Alloc::template rebind<Entry>::other::pointer entry_pointer;
36fed23c 59
60 public:
3f2eba6f 61 /// Category.
36fed23c 62 typedef trivial_iterator_tag iterator_category;
63
3f2eba6f 64 /// Difference type.
36fed23c 65 typedef trivial_iterator_difference_type difference_type;
66
3f2eba6f 67 /// Iterator's value type.
36fed23c 68 typedef Value_Type value_type;
69
3f2eba6f 70 /// Iterator's pointer type.
4f4a327e 71 typedef typename _Alloc::template rebind<value_type>::other::pointer
36fed23c 72 pointer;
73
3f2eba6f 74 /// Iterator's const pointer type.
36fed23c 75 typedef
4f4a327e 76 typename _Alloc::template rebind<value_type>::other::const_pointer
36fed23c 77 const_pointer;
78
3f2eba6f 79 /// Iterator's reference type.
36fed23c 80 typedef
4f4a327e 81 typename _Alloc::template rebind<value_type>::other::reference
36fed23c 82 reference;
83
3f2eba6f 84 /// Iterator's const reference type.
36fed23c 85 typedef
4f4a327e 86 typename _Alloc::template rebind<value_type>::other::const_reference
36fed23c 87 const_reference;
88
36fed23c 89 inline
4f4a327e 90 binary_heap_point_const_iterator_(entry_pointer p_e) : m_p_e(p_e)
36fed23c 91 { }
92
3f2eba6f 93 /// Default constructor.
36fed23c 94 inline
4f4a327e 95 binary_heap_point_const_iterator_() : m_p_e(0) { }
36fed23c 96
3f2eba6f 97 /// Copy constructor.
36fed23c 98 inline
4f4a327e 99 binary_heap_point_const_iterator_(const binary_heap_point_const_iterator_& other)
2b31bec4 100 : m_p_e(other.m_p_e)
36fed23c 101 { }
102
3f2eba6f 103 /// Access.
36fed23c 104 inline const_pointer
105 operator->() const
106 {
e4bb1925 107 _GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
76918d89 108 return to_ptr(integral_constant<int, Simple>());
36fed23c 109 }
110
3f2eba6f 111 /// Access.
36fed23c 112 inline const_reference
113 operator*() const
114 {
e4bb1925 115 _GLIBCXX_DEBUG_ASSERT(m_p_e != 0);
76918d89 116 return *to_ptr(integral_constant<int, Simple>());
36fed23c 117 }
118
3f2eba6f 119 /// Compares content to a different iterator object.
36fed23c 120 inline bool
4f4a327e 121 operator==(const binary_heap_point_const_iterator_& other) const
2b31bec4 122 { return m_p_e == other.m_p_e; }
36fed23c 123
3f2eba6f 124 /// Compares content (negatively) to a different iterator object.
36fed23c 125 inline bool
4f4a327e 126 operator!=(const binary_heap_point_const_iterator_& other) const
2b31bec4 127 { return m_p_e != other.m_p_e; }
36fed23c 128
129 private:
130 inline const_pointer
131 to_ptr(true_type) const
2b31bec4 132 { return m_p_e; }
36fed23c 133
134 inline const_pointer
135 to_ptr(false_type) const
2b31bec4 136 { return *m_p_e; }
36fed23c 137
138 public:
139 entry_pointer m_p_e;
140 };
36fed23c 141 } // namespace detail
b34535d7 142} // namespace __gnu_pbds
36fed23c 143
2b31bec4 144#endif