Mercurial > hg > Game > Cerium
annotate example/task_queue/testQueueInfo.cc @ 1407:976f7b77f0bf draft
fix Makefile
author | Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 17 Feb 2012 17:42:50 +0900 |
parents | efee36d2f84c |
children |
rev | line source |
---|---|
819 | 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 | |
820
3c508c837ad8
give up singleton pattern.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
819
diff
changeset
|
9 static QueueInfo<TaskList> *queuePool = new QueueInfo<TaskList>() ; |
819 | 10 |
11 void | |
12 queueInfoTest(int count) | |
13 { | |
14 | |
820
3c508c837ad8
give up singleton pattern.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
819
diff
changeset
|
15 QueueInfo<TaskList> *q = new QueueInfo<TaskList>(queuePool) ; |
3c508c837ad8
give up singleton pattern.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
819
diff
changeset
|
16 QueueInfo<TaskList> *r = new QueueInfo<TaskList>(queuePool) ; |
819 | 17 |
18 int i = 0; | |
19 for (i = 0; i < count; i++) { | |
20 q->addLast(q->create()); | |
21 } | |
822 | 22 i = 0; |
819 | 23 for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { |
822 | 24 t->length = i++; |
25 | |
819 | 26 } |
27 | |
28 i = 0; | |
29 for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { | |
961 | 30 printf(" No. %d %d\n", i++, t->length); |
819 | 31 } |
32 | |
961 | 33 printf("First %d\n", q->getFirst()->length); |
34 printf("Last %d\n", q->getLast()->length); | |
819 | 35 |
36 TaskListPtr t = q->poll(); | |
961 | 37 printf("Polled %d\n", t->length); |
819 | 38 q->free_(t); |
39 | |
40 printf("Length %d = %d - 1\n", q->length(), count); | |
41 | |
822 | 42 q->moveToFirst(q->get(count-2)); |
819 | 43 |
44 i = 0; | |
45 for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { | |
961 | 46 printf(" No. %d %d\n", i++, t->length); |
819 | 47 } |
48 | |
822 | 49 while(!q->empty()){ |
819 | 50 r->addFirst(q->poll()); |
51 } | |
52 | |
53 i = 0; | |
54 for(TaskListPtr t= r->getFirst(); t ;t = r->getNext(t) ) { | |
961 | 55 printf(" No. %d %d\n", i++, t->length); |
819 | 56 } |
57 | |
58 | |
59 } | |
60 | |
61 /* end */ |