Fix erreur de calculs de pointeurs

This commit is contained in:
Timothée Leclaire-Fournier 2024-01-22 20:10:37 -05:00
parent b9d1d04462
commit 3451a57bcf
3 changed files with 6 additions and 9 deletions

View File

@ -1,9 +1,7 @@
#pragma once
#include <string>
#include <array>
#include <optional>
#include <bitset>
#include <GOL.h>
#include "GridTeamH.h"

View File

@ -1,6 +1,6 @@
#include "GridTeamH.h"
#include "GOL.h"
#include <iostream>
#include <algorithm>
// Constructeur Grid par défaut
GridTeamH::GridTeamH()
@ -25,8 +25,8 @@ void GridTeamH::resize(size_t width, size_t height, CellType initValue)
{
mWidth = width;
mHeight = height;
mData.resize((width * height) + width);
mIntermediateData.resize((width * height) + width);
mData.resize(width * height);
mIntermediateData.resize(width * height);
fill(initValue, false);
}
@ -170,21 +170,21 @@ void GridTeamH::fillBorder(CellType value)
}
// DROITE
e_ptr += mWidth * mHeight;
e_ptr += mWidth * (mHeight - 1);
while (ptr < e_ptr) {
*ptr = value;
ptr += mWidth;
}
// DESSOUS
e_ptr -= mWidth;
e_ptr -= (mWidth - 1);
while (ptr > e_ptr) {
*ptr = value;
ptr--;
}
// GAUCHE
e_ptr -= mWidth * mHeight;
e_ptr -= mWidth * (mHeight - 1);
while (ptr > e_ptr) {
*ptr = value;
ptr -= mWidth;

View File

@ -1,6 +1,5 @@
#pragma once
#include <algorithm>
#include <vector>
#include <random>
#include "GOL.h"