history.cpp 588 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
/**
\file history.h
\date 24/04/2021
\author Merwane Bouri
\version 1
\brief History

Cette classe représente un historique de Grids.

        **/

12
#include "history.hpp"
13
14
15
16
17
18
19

#include <cassert>

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

20
void History::pushGrid(const Grid &g){
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
    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;
    }
36
    throw HistoryException("Empty stack");
37
}