Mercurial > hg > Members > e085722 > Cerium
diff 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 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/task_queue/testQueueInfo.cc Mon Nov 08 01:23:25 2010 +0900 @@ -0,0 +1,61 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "QueueInfo.h" +#include "TaskList.h" +#include "Func.h" + + +static QueueInfo<TaskList> *queuePool = new QueueInfo<TaskList>() ; + +void +queueInfoTest(int count) +{ + + QueueInfo<TaskList> *q = new QueueInfo<TaskList>(queuePool) ; + QueueInfo<TaskList> *r = new QueueInfo<TaskList>(queuePool) ; + + int i = 0; + for (i = 0; i < count; i++) { + q->addLast(q->create()); + } + i = 0; + for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { + t->length = i++; + + } + + i = 0; + for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { + printf(" No. %d %d\n", i++, t->length); + } + + printf("First %d\n", q->getFirst()->length); + printf("Last %d\n", q->getLast()->length); + + TaskListPtr t = q->poll(); + printf("Polled %d\n", t->length); + q->free_(t); + + printf("Length %d = %d - 1\n", q->length(), count); + + q->moveToFirst(q->get(count-2)); + + i = 0; + for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { + printf(" No. %d %d\n", i++, t->length); + } + + while(!q->empty()){ + r->addFirst(q->poll()); + } + + i = 0; + for(TaskListPtr t= r->getFirst(); t ;t = r->getNext(t) ) { + printf(" No. %d %d\n", i++, t->length); + } + + +} + +/* end */