parent
ba5209aa4b
commit
9cc5075531
|
@ -69,13 +69,24 @@ char *taskToStr(Task *t) {
|
|||
}
|
||||
|
||||
// for llist
|
||||
int cmpTask(void *a, void *b) {
|
||||
|
||||
// compare task by name
|
||||
int cmpTaskN(void *a, void *b) {
|
||||
Task *aa = (Task *)a;
|
||||
Task *bb = (Task *)b;
|
||||
return strcmp(aa->name, bb->name);
|
||||
}
|
||||
|
||||
// compare task by priority
|
||||
int cmpTaskP(void *a, void *b) {
|
||||
Task *aa = (Task *)a;
|
||||
Task *bb = (Task *)b;
|
||||
return aa->priority - bb->priority;
|
||||
}
|
||||
|
||||
// cmp event by task name
|
||||
int cmpEvent(void *a, void *b) {
|
||||
Event *aa = (Event *)a;
|
||||
Event *bb = (Event *)b;
|
||||
return cmpTask(aa->task, bb->task);
|
||||
return cmpTaskN(aa->task, bb->task);
|
||||
}
|
||||
|
|
|
@ -29,7 +29,8 @@ Task *newTask(char *n, time_t c, time_t d, int p, uint64_t sp);
|
|||
/*
|
||||
* compare function for Task
|
||||
*/
|
||||
int cmpTask(void *a, void *b);
|
||||
int cmpTaskN(void *a, void *b);
|
||||
int cmpTaskP(void *a, void *b);
|
||||
|
||||
/*
|
||||
* return allocated string representation of Task
|
||||
|
|
|
@ -22,7 +22,7 @@ int main() {
|
|||
printf("%s\n", ctime(&now));
|
||||
|
||||
// new llist test
|
||||
llist *list1 = llistNew(t1, cmpTask);
|
||||
llist *list1 = llistNew(t1, cmpTaskN);
|
||||
llistAppend(list1, &t2);
|
||||
|
||||
// print test tasks
|
||||
|
|
Loading…
Reference in New Issue