history.cpp 588 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
\file history.h
\date 24/04/2021
\author Merwane Bouri
\version 1
\brief History

Cette classe représente un historique de Grids.

        **/

#include "history.h"

#include <cassert>

History::History(unsigned int nbM){
    nbMax=nbM;
}

void History::pushGrid(Grid g){
    if(tab.size()==nbMax){
        tab.pop_front();
        tab.push_back(g);
    }
    else{
        tab.push_back(g);
    }
}

Grid History::popGrid(){
    if(tab.size()>0){
        Grid tmp = tab.back();
        tab.pop_back();
        return tmp;
    }
Merwane Bouri's avatar
Merwane Bouri committed
36
    throw HistoryException("La pile est vide. \n");
37
}