forked from George-Britton/AI_Search_Algorithms
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPlayer.cpp
More file actions
30 lines (24 loc) · 639 Bytes
/
Player.cpp
File metadata and controls
30 lines (24 loc) · 639 Bytes
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
#include "Player.h"
// Get from front of queue
int Player::GetFIFO()
{
// null check
if (this->FIFOQueue.empty()) return 0;
// Get the value of the front element
int FrontElem = *this->FIFOQueue.begin();
// Remove the element from the front of the queue
this->FIFOQueue.erase(this->FIFOQueue.begin());
this->FIFOQueue.shrink_to_fit();
return FrontElem;
}
// Get from top of queue
int Player::GetFILO()
{
// null check
if (this->FILOStack.empty()) return 0;
// Get the value of the top element of the stack
int TopElem = *this->FILOStack.end();
// Remove element from stack
this->FILOStack.pop_back();
return TopElem;
}