Mercurial > hg > Members > kono > Cerium
changeset 822:ba45c7b81d2a
testQueueInfo 100% passed
author | game@zeus.cr.ie.u-ryukyu.ac.jp |
---|---|
date | Sun, 23 May 2010 17:14:50 +0900 |
parents | 6e8f8eb1e407 |
children | 01b6d924a560 3468641f22d7 |
files | TaskManager/kernel/ppe/QueueInfo.h example/task_queue/testQueueInfo.cc |
diffstat | 2 files changed, 7 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/QueueInfo.h Sun May 23 16:23:52 2010 +0900 +++ b/TaskManager/kernel/ppe/QueueInfo.h Sun May 23 17:14:50 2010 +0900 @@ -249,7 +249,7 @@ { T* e = first->next; for (int i = 0; i < index; i++) { - if (e == this) return NULL; + if (e->next == this) return NULL; e = e->next; } return e; @@ -283,7 +283,7 @@ template<typename T>int QueueInfo<T>::length() { - int i = 1; + int i = 0; if (empty()) return 0; T* e = first; while((e = e->next) != this ) i++;
--- a/example/task_queue/testQueueInfo.cc Sun May 23 16:23:52 2010 +0900 +++ b/example/task_queue/testQueueInfo.cc Sun May 23 17:14:50 2010 +0900 @@ -20,9 +20,10 @@ 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; + t->length = i++; + } i = 0; @@ -39,14 +40,14 @@ printf("Length %d = %d - 1\n", q->length(), count); - q->moveToFirst(q->get(count-1)); + q->moveToFirst(q->get(count-2)); i = 0; for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { printf(" No. %d %ld\n", i++, t->length); } - for(TaskListPtr t= q->getFirst(); t ;t = q->getNext(t) ) { + while(!q->empty()){ r->addFirst(q->poll()); }