Mercurial > hg > Members > e085722 > Cerium
comparison example/task_queue/testQueueInfo.cc @ 0:04e28d8d3c6f
first commit
author | Daiki KINJYO <e085722@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Nov 2010 01:23:25 +0900 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:04e28d8d3c6f |
---|---|
1 #include <stdio.h> | |
2 #include <stdlib.h> | |
3 #include <string.h> | |
4 #include "QueueInfo.h" | |
5 #include "TaskList.h" | |
6 #include "Func.h" | |
7 | |
8 | |
9 static QueueInfo<TaskList> *queuePool = new QueueInfo<TaskList>() ; | |
10 | |
11 void | |
12 queueInfoTest(int count) | |
13 { | |
14 | |
15 QueueInfo<TaskList> *q = new QueueInfo<TaskList>(queuePool) ; | |
16 QueueInfo<TaskList> *r = new QueueInfo<TaskList>(queuePool) ; | |
17 | |
18 int i = 0; | |
19 for (i = 0; i < count; i++) { | |
20 q->addLast(q->create()); | |
21 } | |
22 i = 0; | |
23 for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { | |
24 t->length = i++; | |
25 | |
26 } | |
27 | |
28 i = 0; | |
29 for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { | |
30 printf(" No. %d %d\n", i++, t->length); | |
31 } | |
32 | |
33 printf("First %d\n", q->getFirst()->length); | |
34 printf("Last %d\n", q->getLast()->length); | |
35 | |
36 TaskListPtr t = q->poll(); | |
37 printf("Polled %d\n", t->length); | |
38 q->free_(t); | |
39 | |
40 printf("Length %d = %d - 1\n", q->length(), count); | |
41 | |
42 q->moveToFirst(q->get(count-2)); | |
43 | |
44 i = 0; | |
45 for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { | |
46 printf(" No. %d %d\n", i++, t->length); | |
47 } | |
48 | |
49 while(!q->empty()){ | |
50 r->addFirst(q->poll()); | |
51 } | |
52 | |
53 i = 0; | |
54 for(TaskListPtr t= r->getFirst(); t ;t = r->getNext(t) ) { | |
55 printf(" No. %d %d\n", i++, t->length); | |
56 } | |
57 | |
58 | |
59 } | |
60 | |
61 /* end */ |