Question
For this lab, you will be implementing both a Last In/First Out and First In/First Out data structures. These data structures store data in a
For this lab, you will be implementing both a Last In/First Out and First In/First Out data structures. These data structures store data in a way that allows you to only see one value from the structure. You can't see any other value in the structure unless it is the top value. These structures are important because they allow us to add or remove data members to the structure in an O(1) complexity.
Lab Instructions
Implement each of the functions to perform the necessary actions outlined in the .h files.
As you are writing your functions, read the instructions and think of how you would test that functions while you are writing it. Write your Test first and then implement your functions. Try running your test and then fixing your issues.
lifo_storage and fifo_storage will both be statically sized, meaning that you don't need to worry about dynamically growing the stringVector. Treat it just like an array.
Fifo
fifo(): Default constructor. Set index properly and reserve 100 spaces in fifo_storage
explicit fifo(std::string input_string): Constructor that does the same thing as the default constructor, but adds a single item to the Fifo
fifo(const fifo &original): Copy constructor
virtual ~fifo(): Destructor
fifo &operator=(const fifo &right): Assignment operator
bool is_empty() const: Return true if the fifo is empty and false if it is not
unsigned size() const: Return the size of the fifo
std::string top() const: Return the front string of the fifo.
void enqueue(std::string input): Add input string to the back of the fifo
void dequeue(): Remove the front string from the fifo
Lifo
lifo(): Default constructor. Set index properly and reserve 100 spaces in fifo_storage
explicit lifo(std::string input_string): Constructor that does the same thing as the default constructor, but adds a single item to the Fifo
lifo(const lifo &original): Copy constructor
virtual ~lifo(): Destructor
lifo &operator=(const lifo &right): Assignment operator
bool is_empty() const: Return true if the lifo is empty and false if it is not
unsigned size() const: Return the size of the lifo
std::string top() const: Return the top of the lifo.
void push(std::string input): Add input string to the top of the string
void pop(): Remove the top string from the lifo
__________________________________________________________________________
Fifo.cpp
fifo::fifo() { //Reserve 100 spaces in fifo_storage } fifo::fifo(std::string input_string) { } fifo::fifo(const fifo &original) { } fifo::~fifo() { } fifo &fifo::operator=(const fifo &right) { //return <#initializer#>; } bool fifo::is_empty(){ return false; } int fifo::size(){ } std::string fifo::top(){ //return std::__cxx11::string(); } void fifo::enqueue(std::string input) { } void fifo::dequeue() { }
__________________________________________________________________________
Fifo.h
class fifo { lab2::stringVector fifo_storage; unsigned front_index; unsigned back_index; public: fifo(); //Default constructor. Reserve 100 spaces in lifo_storage explicit fifo(std::string input_string); //Create new fifo from string input fifo(const fifo &original); //Copy constructor virtual ~fifo(); //Destructor fifo &operator=(const fifo &right); //Assignment operator bool is_empty(); // Return true if the fifo is empty and false if it is not int size(); // Return the size of the fifo std::string top(); // Return the front string of the fifo. void enqueue(std::string input); // Add input string to the back of the fifo void dequeue(); // Remove the front string from the fifo };
__________________________________________________________________________
Lifo.cpp
lifo::lifo() { //Reserve 100 spaces in lifo_storage } lifo::lifo(std::string input_string) { } lifo::lifo(const lifo &original) { } lifo::~lifo() { } lifo &lifo::operator=(const lifo &right) { //return <#initializer#>; } bool lifo::is_empty(){ //return false; } int lifo::size(){ //return 0; } std::string lifo::top(){ //return std::__cxx11::string(); } void lifo::push(std::string input) { } void lifo::pop() { }
__________________________________________________________________________
lifo.h
class lifo { lab2::stringVector lifo_storage; unsigned index; public: lifo(); //Default constructor. Reserve 100 spaces in lifo_storage explicit lifo(std::string input_string); //Create new lifo from string input lifo(const lifo &original); //Copy constructor virtual ~lifo(); //Destructor lifo &operator=(const lifo &right); //Assignment operator bool is_empty(); // Return true if the lifo is empty and false if it is not int size(); // Return the size of the lifo std::string top(); // Return the top of the lifo. void push(std::string input); // Add input string to the top of the string void pop(); // Remove the top string from the lifo };
__________________________________________________________________________
Hi, Can i get help with filling out the implementation files fifo.cpp and lifo.cpp and this is written in C++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started