(C++) Implement a doubly linked list.
Please write simple tests for allfunctions.
Keep track of your edge cases: empty, 1 item, 2+items
You need to update 3 nodes every time you insert or remove: theprevious node, the selected node, and the next node.
node.h file
#ifndef LABS_NODE_H
#define LABS_NODE_H
namespace lab0{
class node{
int data;
public:
node* next;
node* prev;
explicit node(int input_data) : data(input_data), next(nullptr),prev(nullptr){};
int get_data(){return data;};
};
}
#endif
header file
#ifndef DOUBLY_LINKED_LIST_H
#define LABS_DOUBLY_LINKED_LIST_H
#include “node.h”
#include
#include
namespace lab0{
class doubly_linked_list{
lab0::node *head;
lab0::node *tail;
public:
doubly_linked_list();
doubly_linked_list(int input);
doubly_linked_list(std::vector vector_input);
doubly_linked_list(const doubly_linked_list &original);
~doubly_linked_list();
int get_data(unsigned position);
std:vector get_set(unsigned position_from, unsignedposition_to);
unsigned size();
bool is_empty();
void append(int input);
void insert(int input, unsigned location = 0);
void remove(unsigned location);
doubly_linked_list split(unsigned position);
doubly_linked_list split_set(unsigned position_1, unsignedposition_2);
void swap(unsigned position_1, unsigned position_2);
void swap_set(unsigned location_1_start, unsigned location_1_end,unsigned location_2_start, unsigned location_2_end);
void
PayPal Gateway not configured
PayPal Gateway not configured