diff options
author | Christian Schneider | 2019-09-02 17:42:45 +0200 |
---|---|---|
committer | Christian Schneider | 2019-09-02 17:42:45 +0200 |
commit | e3306aa9d6181ef1a72dac0e37a90a9452bc7740 (patch) | |
tree | 90c3466ee0febe648cb52f59d1f422e7105d233f | |
parent | deb0c4093407b694e847862c6447a501beaaa018 (diff) | |
download | itools-e3306aa9d6181ef1a72dac0e37a90a9452bc7740.tar.gz itools-e3306aa9d6181ef1a72dac0e37a90a9452bc7740.tar.bz2 itools-e3306aa9d6181ef1a72dac0e37a90a9452bc7740.zip |
Remove usage of reset()/each() for iterator
-rw-r--r-- | it_pipe.class | 12 |
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; } |