Change Model::row_data to return an Option<T> (#873)

Change Model::row_data to return an Option<T> (rust) or std::optional<T> (c++)

Co-authored-by: Olivier Goffart <olivier@woboq.com>
Co-authored-by: Simon Hausmann <hausmann@gmail.com>
This commit is contained in:
Tobias Hunger 2022-01-26 13:55:38 +01:00 committed by GitHub
parent e2ec76f9ef
commit e3c4209b1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
24 changed files with 229 additions and 102 deletions

View file

@ -15,8 +15,8 @@ int main()
std::vector<TileData> new_tiles;
new_tiles.reserve(old_tiles->row_count() * 2);
for (int i = 0; i < old_tiles->row_count(); ++i) {
new_tiles.push_back(old_tiles->row_data(i));
new_tiles.push_back(old_tiles->row_data(i));
new_tiles.push_back(*old_tiles->row_data(i));
new_tiles.push_back(*old_tiles->row_data(i));
}
std::default_random_engine rng {};
std::shuffle(new_tiles.begin(), new_tiles.end(), rng);
@ -33,7 +33,7 @@ int main()
int first_visible_index = -1;
TileData first_visible_tile;
for (int i = 0; i < tiles_model->row_count(); ++i) {
auto tile = tiles_model->row_data(i);
auto tile = *tiles_model->row_data(i);
if (!tile.image_visible || tile.solved)
continue;
if (first_visible_index == -1) {

View file

@ -16,8 +16,8 @@ int main()
std::vector<TileData> new_tiles;
new_tiles.reserve(old_tiles->row_count() * 2);
for (int i = 0; i < old_tiles->row_count(); ++i) {
new_tiles.push_back(old_tiles->row_data(i));
new_tiles.push_back(old_tiles->row_data(i));
new_tiles.push_back(*old_tiles->row_data(i));
new_tiles.push_back(*old_tiles->row_data(i));
}
std::default_random_engine rng {};
std::shuffle(new_tiles.begin(), new_tiles.end(), rng);