From 49ad0b5252190ffbfb4511131af2032f7f341a60 Mon Sep 17 00:00:00 2001 From: Sebastian Geerken Date: Tue, 5 Mar 2013 00:27:05 +0100 Subject: Implemented iterators for Vector. --- lout/container.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'lout/container.cc') diff --git a/lout/container.cc b/lout/container.cc index deeede57..6a55fc2c 100644 --- a/lout/container.cc +++ b/lout/container.cc @@ -193,13 +193,22 @@ void Vector::sort() qsort(array, numElements, sizeof(Object*), misc::Comparable::compareFun); } +Object *Vector::VectorIterator::getNext() +{ + if (index < vector->numElements - 1) + index++; + + return index < vector->numElements ? vector->array[index] : NULL; +} + +bool Vector::VectorIterator::hasNext() +{ + return index < vector->numElements - 1; +} -/** - * \bug Not implemented. - */ Collection0::AbstractIterator* Vector::createIterator() { - return NULL; + return new VectorIterator(this); } // ------------ -- cgit v1.2.3