summaryrefslogtreecommitdiff
path: root/it_pipe.class
diff options
context:
space:
mode:
authorChristian Schneider2019-09-02 17:42:45 +0200
committerChristian Schneider2019-09-02 17:42:45 +0200
commite3306aa9d6181ef1a72dac0e37a90a9452bc7740 (patch)
tree90c3466ee0febe648cb52f59d1f422e7105d233f /it_pipe.class
parentdeb0c4093407b694e847862c6447a501beaaa018 (diff)
downloaditools-e3306aa9d6181ef1a72dac0e37a90a9452bc7740.tar.gz
itools-e3306aa9d6181ef1a72dac0e37a90a9452bc7740.tar.bz2
itools-e3306aa9d6181ef1a72dac0e37a90a9452bc7740.zip
Remove usage of reset()/each() for iterator
Diffstat (limited to 'it_pipe.class')
-rw-r--r--it_pipe.class12
1 files changed, 6 insertions, 6 deletions
diff --git a/it_pipe.class b/it_pipe.class
index cd1b54f..e23f7e8 100644
--- a/it_pipe.class
+++ b/it_pipe.class
@@ -6,6 +6,7 @@ class it_pipe implements Iterator
var $lines; # all lines currently in pipe
var $_valid;
+ var $_position;
/**
* Creates a pipe object from input. Named arguments:
@@ -50,28 +51,27 @@ function __toString()
#
function rewind()
{
- reset($this->lines);
- $this->next();
+ $this->_position = 0;
}
function next()
{
- $this->_valid = each($this->lines);
+ $this->_position++;
}
function valid()
{
- return $this->_valid;
+ return isset($this->lines[$this->_position]);
}
function current()
{
- return $this->_valid[1];
+ return $this->lines[$this->_position];
}
function key()
{
- return $this->_valid[0];
+ return $this->_position;
}