aboutsummaryrefslogtreecommitdiff
path: root/lout/container.cc
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2013-03-05 00:27:05 +0100
committerSebastian Geerken <devnull@localhost>2013-03-05 00:27:05 +0100
commit49ad0b5252190ffbfb4511131af2032f7f341a60 (patch)
treed2de69d360e2feff519835cc1fef0d8b3217afc1 /lout/container.cc
parent0128efee08d42bd4efa1fda3bc12664b216712ae (diff)
Implemented iterators for Vector.
Diffstat (limited to 'lout/container.cc')
-rw-r--r--lout/container.cc17
1 files changed, 13 insertions, 4 deletions
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);
}
// ------------