From af9e9e64a8dea21868cf3474cda6b8a85ac05442 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 1 Nov 2022 21:21:21 +0100 Subject: iterator stuff --- src/chunk.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/chunk.cpp') diff --git a/src/chunk.cpp b/src/chunk.cpp index 59e05d73..b78b8f1a 100644 --- a/src/chunk.cpp +++ b/src/chunk.cpp @@ -19,4 +19,19 @@ bool chunk::empty(bool force) const noexcept return true; } +tile_ref chunk::operator[](std::size_t idx) noexcept { return { *this, std::uint8_t(idx) }; } +tile_proto chunk::operator[](std::size_t idx) const noexcept { return tile_proto(tile_ref { *const_cast(this), std::uint8_t(idx) }); } +tile_ref chunk::operator[](local_coords xy) noexcept { return operator[](xy.to_index()); } +tile_proto chunk::operator[](local_coords xy) const noexcept { return operator[](xy.to_index()); } + +auto chunk::begin() noexcept -> iterator { return iterator { *this, 0 }; } +auto chunk::end() noexcept -> iterator { return iterator { *this, TILE_COUNT }; } +auto chunk::cbegin() const noexcept -> const_iterator { return const_iterator { *this, 0 }; } +auto chunk::cend() const noexcept -> const_iterator { return const_iterator { *this, TILE_COUNT }; } +auto chunk::begin() const noexcept -> const_iterator { return cbegin(); } +auto chunk::end() const noexcept -> const_iterator { return cend(); } + +chunk::chunk(chunk&&) noexcept = default; +chunk& chunk::operator=(chunk&&) noexcept = default; + } // namespace floormat -- cgit v1.2.3