class FIFO {
private:
int maximum;
int head;
int counter;
int** elements;
public:
void empty()
bool isEmpty()
void in(int number)
void out()
int first()
}
void FIFO::empty() {
head = 0;
counter = 0;
}
bool FIFO::isempty() {
return counter == 0;
}
void FIFO::in(int number) {
if (counter == max) {
throw runtime_error("Túlcsordulás")
} else {
elements[head] = number;
head = (head + 1) % maximum;
counter = counter + 1;
}
}
void FIFO::out() {
if (counter == 0) {
throw runtime_error("Alúlcsordulás")
} else {
if (head == 0) {
head = maximum;
} else {
head = head - 1;
}
counter = counter - 1;
}
}
int FIFO::first() {
if (counter == 0) {
throw runtime_error("Alulcsordulás")
} else {
return elements[head - 1]
}
}