26 #include <olp/core/CoreApi.h>
27 #include <olp/core/geo/tiling/TileKey.h>
40 class Iterator :
public std::iterator<std::forward_iterator_tag, TileKey> {
75 bool operator==(
Iterator& other)
const;
84 bool operator!=(
Iterator& other)
const;
90 std::uint32_t index_{0};
104 std::uint16_t mask = ~0);
129 void Skip(std::uint32_t& index)
const;
132 const std::uint32_t level_{0};
133 const std::uint32_t count_{0};
134 const std::uint16_t mask_{0};
135 const std::uint32_t shift_{0};
138 inline SubTiles::Iterator::Iterator(
const SubTiles& parent, std::uint32_t index)
139 : parent_(parent), index_(index) {
141 parent_.Skip(index_);
145 const TileKey& parent_key = parent_.tile_key_;
146 const std::uint32_t sub_level = parent_.level_;
149 (parent_key.
Row() << sub_level) | (index_ >> sub_level),
150 (parent_key.
Column() << sub_level) | (index_ & ((1 << sub_level) - 1)),
151 parent_key.
Level() + sub_level);
155 parent_.Skip(++index_);
161 parent_.Skip(++index_);
166 return parent_.tile_key_ == other.parent_.tile_key_ && index_ == other.index_;
170 return !(*
this == other);
175 : tile_key_(tile_key),
177 count_(1 << (level_ << 1)),
179 shift_(level_ > 2 ? (level_ - 2) << 1 : 0) {}
203 inline void SubTiles::Skip(std::uint32_t& index)
const {
204 if (mask_ ==
static_cast<std::uint16_t
>(-1))
207 while (index < count_ && (mask_ & (1 << (index >> shift_))) == 0)
The tile key iterator.
Definition: SubTiles.h:40
bool operator==(Iterator &other) const
Checks whether the iterators are equal.
Definition: SubTiles.h:165
ValueType operator*() const
Gets a reference to the tile key.
Definition: SubTiles.h:144
bool operator!=(Iterator &other) const
Checks whether the iterators are not equal.
Definition: SubTiles.h:169
Iterator & operator++()
Iterates to the next tile.
Definition: SubTiles.h:154
A container of child tiles.
Definition: SubTiles.h:35
ConstIterator cend() const
Returns a constant iterator to the end of the container.
Definition: SubTiles.h:199
Iterator begin()
Returns an iterator to the beginning.
Definition: SubTiles.h:183
Iterator ConstIterator
An alias for the iterator.
Definition: SubTiles.h:94
SubTiles(const TileKey &tile_key, std::uint32_t level=1, std::uint16_t mask=~0)
Creates a SubTiles instance.
Definition: SubTiles.h:173
size_t Size() const
Gets the size of the child tile.
Definition: SubTiles.h:181
Iterator end()
Returns an iterator to the end.
Definition: SubTiles.h:185
ConstIterator cbegin() const
Returns a constant iterator to the beginning of the container.
Definition: SubTiles.h:195
Addresses a tile in a quadtree.
Definition: TileKey.h:63
static TileKey FromRowColumnLevel(std::uint32_t row, std::uint32_t column, std::uint32_t level)
Creates a tile key.
constexpr std::uint32_t Column() const
Gets the tile column.
Definition: TileKey.h:219
constexpr std::uint32_t Row() const
Gets the tile row.
Definition: TileKey.h:200
constexpr std::uint32_t Level() const
Gets the tile level.
Definition: TileKey.h:191
Rules all the other namespaces.
Definition: AppleSignInProperties.h:24