Додаток А
Конструювання АТД – список
файл element.h
#include<iostream>
usingnamespace std;
class element
{
public:
int value;
element *prew;
element *next;
};
файл list.h
#include"element.h"
class List
{
public:
List(){
head=0;
tail=0;
}
virtual~List(){
head=head->next;
while(head){
delete head->prew;
head=head->next;
}
}
void push_first(int x){
element *temp = new element;
temp->value = x;
temp->prew = 0;
temp->next = head;
head = temp;
if(!head->next)
tail=head;
}
void push_last(int x){
element *temp = new element;
temp->value = x;
temp->next = 0;
tail->next=temp;
temp->prew = tail;
tail = temp;
}
void push_after(element *pos,int x){
element *temp = new element;
temp->next = pos->next;
pos->next->prew = temp;
pos->next = temp;
temp->prew = pos;
temp->value = x;
}
void push(int x){