2017_22
This commit is contained in:
@@ -80,6 +80,7 @@ auto operator*=(Coord &, std::int64_t) -> Coord &;
|
||||
template<>
|
||||
struct std::hash<aocpp::Coord>
|
||||
{
|
||||
using is_transparent = void;
|
||||
auto operator()(aocpp::Coord const& c) const noexcept -> std::size_t {
|
||||
std::hash<std::int64_t> h;
|
||||
return h(c.x) ^ h(c.y);
|
||||
|
@@ -1,11 +1,12 @@
|
||||
#ifndef AOCPP_GRID_HPP_
|
||||
#define AOCPP_GRID_HPP_
|
||||
|
||||
#include <concepts>
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include <type_traits>
|
||||
#include <stdexcept>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <aocpp/Coord.hpp>
|
||||
|
||||
@@ -62,8 +63,14 @@ struct Grid {
|
||||
return result;
|
||||
}
|
||||
|
||||
template <typename F>
|
||||
auto each(F f = F{}) const {
|
||||
/**
|
||||
* @brief Apply the callback function across all elements of the grid.
|
||||
*
|
||||
* @tparam F Type of callback
|
||||
* @param f Callback function
|
||||
*/
|
||||
template <std::invocable<Coord, char> F>
|
||||
auto each(F f = F{}) const -> void {
|
||||
auto const h = rows.size();
|
||||
for (std::size_t y = 0; y < h; y++) {
|
||||
auto const& row = rows[y];
|
||||
|
Reference in New Issue
Block a user