Region::const_iterator Board::find(const Region& ss, const Piece &value) const { for (auto s = ss.cbegin(); s != ss.cend(); s++) { if (at(s->file(),s->rank()) == value) return s; } return ss.cend(); }
int Board::count_repeats(const Region& ss, const Piece &value) const { int result = 0; bool repeating = false; int count = 0; for (auto s = ss.cbegin(); s != ss.cend(); s++) if (at(s->file(),s->rank()) == value) { if (repeating) count++; else count = 1; if (count > result) result = count; repeating = true; } else repeating = false; return result; }
void Board::operator()(const Region& ss, const Piece &value) { for (auto s = ss.cbegin(); s != ss.cend(); s++) place(s->file(),s->rank(),value); }