This repository has been archived on 2024-01-06. You can view files and clone it, but cannot push or open issues or pull requests.
justhomework/DataStructure/Code/ex05/list.h

59 lines
1 KiB
C
Raw Normal View History

2021-10-21 16:13:46 +00:00
#include <iostream>
#include <string>
#define Node node *
typedef struct node
{
int data;
Node pred;
Node succ;
} node;
class List
{
private:
Node header = new node;
Node trailer = new node;
int _size;
protected:
2021-10-23 02:54:30 +00:00
Node firstInsertN(Node New);
Node lastInsertN(Node New);
Node succInsertN(Node old, Node ne);
Node predInsertN(Node old, Node ne);
void removeN(Node i);
Node searchN(int value,int n,Node p);
2021-10-21 16:13:46 +00:00
public:
2021-10-22 11:25:46 +00:00
int getSize()
{
return _size;
}
2021-10-21 16:13:46 +00:00
List();
2021-10-22 11:25:46 +00:00
~List();
void clear();
2021-10-21 16:13:46 +00:00
Node first() { return header->succ; }
Node last() { return trailer->pred; }
2021-10-27 15:40:44 +00:00
int firstInsert(int New);
int lastInsert(int New);
2021-10-21 16:13:46 +00:00
Node succInsert(Node Old, int New);
Node predInsert(Node Old, int New);
2021-10-23 02:54:30 +00:00
2021-10-21 16:13:46 +00:00
int get(int i);
Node find(int i);
2021-10-22 11:25:46 +00:00
int remove(int i);
2021-10-23 02:54:30 +00:00
Node searchN(int value,int n);
int valid(Node p);
2021-10-22 11:25:46 +00:00
void sort();
2021-10-21 16:13:46 +00:00
int operator[](int i)
{
Node p = first();
while (0 < i--)
p = p->succ;
return p->data;
}
};