Loading...
Searching...
No Matches
piercedKernelIterator.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_PIERCED_KERNEL_ITERATOR_HPP__
26#define __BITPIT_PIERCED_KERNEL_ITERATOR_HPP__
27
28#include <cassert>
29#include <iterator>
30#include <limits>
31#include <type_traits>
32
33namespace bitpit{
34
35template<typename id_t>
36class PiercedKernel;
37
45template<typename id_t = long>
47 : public std::iterator<std::random_access_iterator_tag, id_t, std::ptrdiff_t, id_t*, id_t&>
48{
49
50template<typename PK_id_t>
51friend class PiercedKernel;
52
53template<typename PSI_value_t, typename PSI_id_t, typename PSI_value_no_cv_t>
54friend class PiercedStorageIterator;
55
56private:
60 template<typename PK_id_t>
62
69 typedef Kernel<id_t> kernel_t;
70
71public:
75 typedef std::bidirectional_iterator_tag iterator_category;
76
80 typedef id_t value_type;
81
85 typedef std::ptrdiff_t difference_type;
86
90 typedef const id_t * pointer;
91
95 typedef const id_t & reference;
96
101
105 typedef id_t id_type;
106
107 // Constructors
109
110 // General methods
111 void swap(PiercedKernelIterator& other) noexcept;
112
113 const kernel_type & getKernel() const;
114
115 // Methos to extract information on the current element
116 id_t getId(const id_t &fallback = -1) const noexcept;
117 std::size_t getRawIndex() const noexcept;
118 std::size_t getPos() const noexcept;
119
120 // Operators
121 PiercedKernelIterator& operator++();
122 PiercedKernelIterator operator++(int);
123
124 PiercedKernelIterator& operator--();
125 PiercedKernelIterator operator--(int);
126
127 const id_t & operator*() const;
128 const id_t * operator->() const;
129
133 bool operator==(const PiercedKernelIterator &rhs) const
134 {
135 return (m_kernel == rhs.m_kernel) && (m_pos == rhs.m_pos);
136 }
137
141 bool operator!=(const PiercedKernelIterator &rhs) const
142 {
143 return (m_kernel != rhs.m_kernel) || (m_pos != rhs.m_pos);
144 }
145
146private:
150 const kernel_t *m_kernel;
151
155 std::size_t m_pos;
156
157 // Constructors
158 explicit PiercedKernelIterator(const kernel_t *kernel, std::size_t pos);
159
160};
161
162}
163
164// Include the implementation
165#include "piercedKernelIterator.tpp"
166
167#endif
Iterator for the class PiercedKernel.
bool operator!=(const PiercedKernelIterator &rhs) const
std::bidirectional_iterator_tag iterator_category
void swap(PiercedKernelIterator &other) noexcept
std::size_t getPos() const noexcept
std::size_t getRawIndex() const noexcept
id_t getId(const id_t &fallback=-1) const noexcept
const kernel_type & getKernel() const
Metafunction for generating a pierced kernel.
Iterator for the class PiercedStorage.
--- layout: doxygen_footer ---