<commit_before>// See LICENSE file for copyright and license details.

#ifndef CORE__MAP_HPP
#define CORE__MAP_HPP

#include "core/tile.hpp"
#include <vector>

class Map {
public:
  Map(const V2i& size);
  ~Map();

  void resize(const V2i& size);
  const V2i& size() const;

  bool isInboard(const V2i& pos) const;

  const Tile& tile(const V2i& pos) const;
  Tile& tile(const V2i& pos);

  V2i incV2i(const V2i& pos) const;

  template <class Func>
  void forEachPos(Func f) {
    for (V2i p = V2i(0, 0); isInboard(p); p = incV2i(p)) {
      f(p);
    }
  }

  template <class Func>
  void forEachTile(Func f) {
    for (Tile& tile : mTiles) {
      f(tile);
    }
  }

private:
  std::vector<Tile> mTiles;
  V2i mSize;
};

#endif
<commit_msg>core/map.hpp: Simplified forEachPos()<commit_after>// See LICENSE file for copyright and license details.

#ifndef CORE__MAP_HPP
#define CORE__MAP_HPP

#include "core/tile.hpp"
#include <vector>

class Map {
public:
  Map(const V2i& size);
  ~Map();

  void resize(const V2i& size);
  const V2i& size() const;

  bool isInboard(const V2i& pos) const;

  const Tile& tile(const V2i& pos) const;
  Tile& tile(const V2i& pos);

  V2i incV2i(const V2i& pos) const;

  template <class Func>
  void forEachPos(Func f) {
    for (V2i p(0, 0); isInboard(p); p = incV2i(p)) {
      f(p);
    }
  }

  template <class Func>
  void forEachTile(Func f) {
    for (Tile& tile : mTiles) {
      f(tile);
    }
  }

private:
  std::vector<Tile> mTiles;
  V2i mSize;
};

#endif

{'fraction_non_alphanumeric': 0.13678618857901725, 'fraction_numerical': 0.019256308100929615, 'mean_word_length': 3.318051575931232, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2913403', 'n_tokens_mistral': 641, 'n_tokens_neox': 618, 'n_words': 169}