From b54991f7f2bbce1f15d2b5d561eeef92194e1700 Mon Sep 17 00:00:00 2001 From: Silvio Date: Wed, 11 Aug 2010 17:50:38 -0300 Subject: Fixing iterators' indexes --- classes/iterators/IsisItemIterator.php | 4 ++-- classes/iterators/IsisMainItemIterator.php | 2 +- classes/iterators/IsisMethodIterator.php | 2 +- classes/iterators/IsisRowIterator.php | 2 +- classes/iterators/IsisSubfieldIterator.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) (limited to 'classes/iterators') diff --git a/classes/iterators/IsisItemIterator.php b/classes/iterators/IsisItemIterator.php index 9435146..f5ccd91 100644 --- a/classes/iterators/IsisItemIterator.php +++ b/classes/iterators/IsisItemIterator.php @@ -68,7 +68,7 @@ class IsisItemIterator implements Iterator * Move forward to next element. */ function next() { - if ($this->item >= $this->items) { + if ($this->item >= $this->items - 1) { $this->item = 0; ++$this->row; } @@ -81,6 +81,6 @@ class IsisItemIterator implements Iterator * Check if there is a current element after calls to rewind() or next(). */ function valid() { - return $this->row <= $this->rows; + return $this->row <= $this->rows - 1; } } diff --git a/classes/iterators/IsisMainItemIterator.php b/classes/iterators/IsisMainItemIterator.php index 8bcbfe4..2c1784a 100644 --- a/classes/iterators/IsisMainItemIterator.php +++ b/classes/iterators/IsisMainItemIterator.php @@ -65,7 +65,7 @@ class IsisMainItemIterator implements Iterator * Check if there are more rows. */ function has_more_rows() { - return $this->row <= $this->rows; + return $this->row < $this->rows - 1; } /** diff --git a/classes/iterators/IsisMethodIterator.php b/classes/iterators/IsisMethodIterator.php index 4d2bbd4..e5188d3 100644 --- a/classes/iterators/IsisMethodIterator.php +++ b/classes/iterators/IsisMethodIterator.php @@ -64,6 +64,6 @@ class IsisMethodIterator implements Iterator * Check if there is a current element after calls to rewind() or next(). */ function valid() { - return $this->position <= $this->total; + return $this->position < $this->total - 1; } } diff --git a/classes/iterators/IsisRowIterator.php b/classes/iterators/IsisRowIterator.php index 739db22..0c1463f 100644 --- a/classes/iterators/IsisRowIterator.php +++ b/classes/iterators/IsisRowIterator.php @@ -53,6 +53,6 @@ class IsisRowIterator implements Iterator * Check if there is a current element after calls to rewind() or next(). */ function valid() { - return $this->row <= $this->rows; + return $this->row <= $this->rows - 1; } } diff --git a/classes/iterators/IsisSubfieldIterator.php b/classes/iterators/IsisSubfieldIterator.php index 2e213cf..2bc57c0 100644 --- a/classes/iterators/IsisSubfieldIterator.php +++ b/classes/iterators/IsisSubfieldIterator.php @@ -60,7 +60,7 @@ class IsisSubfieldIterator implements Iterator * Move forward to next element. */ function next() { - if ($this->subfield >= $this->subfields) { + if ($this->subfield >= $this->subfields - 1) { $this->subfield = 0; ++$this->row; } @@ -73,6 +73,6 @@ class IsisSubfieldIterator implements Iterator * Check if there is a current element after calls to rewind() or next(). */ function valid() { - return $this->row <= $this->rows; + return $this->row <= $this->rows - 1; } } -- cgit v1.2.3