#pragma once #include "tile.hpp" #include "tile-iterator.hpp" #include #include namespace floormat { template class basic_tile_iterator; struct chunk final { tile& operator[](local_coords xy) { return _tiles[xy.to_index()]; } const tile& operator[](local_coords xy) const { return _tiles[xy.to_index()]; } tile& operator[](std::size_t i) { return _tiles[i]; } const tile& operator[](std::size_t i) const { return _tiles[i]; } const auto& tiles() const { return _tiles; } auto& tiles() { return _tiles; } using iterator = basic_tile_iterator; using const_iterator = basic_tile_iterator; iterator begin() { return iterator{_tiles.data(), 0}; } iterator end() { return iterator{_tiles.data(), _tiles.size()}; } const_iterator cbegin() const { return const_iterator{_tiles.data(), 0}; } const_iterator cend() const { return const_iterator{_tiles.data(), _tiles.size()}; } const_iterator begin() const { return cbegin(); } const_iterator end() const { return cend(); } bool empty() const; chunk() = default; chunk(chunk&&) = default; chunk& operator=(chunk&&) = default; fm_DECLARE_DELETED_COPY_ASSIGNMENT(chunk); private: std::array _tiles = {}; mutable bool _maybe_empty = true; }; } // namespace floormat