forked from ASD-ADF/ASD_Task_3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.h
73 lines (56 loc) · 1.4 KB
/
list.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef LIST_H_INCLUDED
#define LIST_H_INCLUDED
#include <iostream>
#include "my_data.h"
#define first(L) L.first
#define last(L) L.last
#define next(P) P->next
#define prev(P) P->prev
#define info(P) P->info
using namespace std;
/**
* Type infotype : mytype
* Type address : pointer to ElmList
*
* Type ElmList <
* info : infotype
* next : address
* prev : address
* >
*
* Type List : <
* first : address
* last : address
* >
*
**/
typedef mytype infotype;
typedef struct elmlist *address;
struct elmlist{
//------------- your code here -----------
address prev;
address next;
infotype info;
//----------------------------------------
};
struct List{
//------------- your code here -----------
address first;
address last;
//----------------------------------------
};
// define a function and a procedure to allocate and deallocate an element list
void createList(List &L);
address allocate(infotype x);
void deallocate(address &P);
// define insert and delete procedure
void insertFirst(List &L, address P);
void insertLast(List &L, address P);
void deleteFirst(List &L, address &P);
void deleteLast(List &L, address &P);
void insertAfter(List &L, address Prec, address P);
void deleteAfter(List&L, address Prec, address &P);
// define search-by-ID function and view procedure
address findElm(List L, infotype x);
void printInfo(List L);
#endif // LIST_H_INCLUDED