Newer
Older
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
#include <bwio.h>
#include <priority-q.h>
int ASCII2NUM(char ch){
if(ch >= '0' && ch<= '9') return ch-'0';
if(ch >= 'a' && ch<= 'f') return ch-'a'+10;
if(ch>= 'A' && ch<= 'F') return ch-'A'+10;
return -1;
}
int TDPQReady(TDPQ* PQ)
{
int ready =((PQ!=0) && (PQ->Head!=0) &&(PQ->Tail!=0))? 1:0;
return ready;
}
int PushToTDPQ(TDPQ *PQ, TD* Task)
{
if(TDPQReady(PQ)){
// b26feng: TODO : check if Task is valid
PQ->Tail->Next = Task;
PQ->Tail = Task;
PQ->Lenght = PQ->Length + 1;
}else return -1;
}
TD* TDPQGetStart(TDPQ* PQ)
{
if(BufferReady(Buf)){
return PQ->Head;
}else return -1;
}
int TDPQPopStart(TDPQ* PQ)
{
if(BufferReady(Buf)){
PQ->Head = PQ->Head->Next;
PQ->Length = PQ->Length - 1;
}else return -1;
}