Cursor &Cursor::operator++() { // Either this is the end cursor, or the current position is valid. assert(piece == pieceEnd || position != piece->end); // If we are already the end cursor, don't move. if(piece == pieceEnd) return *this; // Increment the position. If we've reached the end of the piece, // move to the next piece and reset the position instead. If there // are no more piece, just reset to being the end cursor instead. ++position; if(position == piece->end) { ++piece; if(piece == pieceEnd) position = PositionIterator(); else position = piece->begin; } return *this; }
PositionIterator positions() { return PositionIterator(h, w); }