-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathline.c
86 lines (78 loc) · 1.78 KB
/
line.c
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
74
75
76
77
78
79
80
81
82
83
84
85
86
#include"line.h"
#include<malloc.h>
#include<ncurses.h>
#include<stdlib.h>
#include<stdio.h>
void initq(line *s){
s->link = (point *)calloc(1,sizeof(point));
//s->link->element = (istack *)calloc(1,sizeof(istack));
inits(&(s->link->element));
s->link->head = NULL;
s->link->tail = NULL;
//printw("%p\n",s->link->tail);
//refresh();
s->front = s->link;
s->lines = 0;
}
void enqueue(line *s){
point *temp = (point *)calloc(1,sizeof(point));
temp->head = s->link;
temp->tail = NULL;
//printw("1\n");
//refresh();
inits(&(temp->element));
s->link->tail = temp;
s->link = temp;
s->lines++;
}
void enqueue_pos(line *l, int a){
point *newnode = (point *)calloc(1,sizeof(point));
inits(&(newnode->element));
point* temp = l->front;
int i = 0;
for(; i < a; i++)
temp = temp->tail;
temp->head->tail = newnode;
newnode->tail = temp;
newnode->head = temp->head;
temp->head = newnode;
l->lines++;
return;
}
void dequeue(line *s){
s->link->head->tail = NULL;
point *temp = s->link;
s->link = s->link->head;
free(temp);
return;
}
void dequeueloc(line *s,int x){
point* temp = s->front;
int num;
int i;
for(i = 0; i < x; i++)
temp = temp->tail;
if(temp->tail == NULL){
dequeue(s);
return;
}
temp->head->tail = temp->tail;
temp->tail->head = temp->head;
s->lines--;
free(temp);
return;
}
int isEmptyq(line *s){
if(s->link->head == s->link->tail)
return 1;
else
return 0;
}
/*int isFull(line *s->link){
if(s->link->i == SIZE -1)
return 1;
else
return 0;
}*/
int ipeepq(line *s){
}