Versions
Look up a class, method, property or event

CStackIterator

Package system.collections
Inheritance class CStackIterator
Implements Iterator, Traversable
Since 1.0
Source Code framework/collections/CStackIterator.php
CStackIterator implements an iterator for CStack.

It allows CStack to return a new iterator for traversing the items in the stack.

Public Methods

Hide inherited methods

MethodDescriptionDefined By
__construct() Constructor. CStackIterator
current() Returns the current array item. CStackIterator
key() Returns the key of the current array item. CStackIterator
next() Moves the internal pointer to the next array item. CStackIterator
rewind() Rewinds internal array pointer. CStackIterator
valid() Returns whether there is an item at current position. CStackIterator

Method Details

__construct() method
public void __construct(array &$data)
$data array the data to be iterated through
Source Code: framework/collections/CStackIterator.php#39 (show)
public function __construct(&$data)
{
    
$this->_d=&$data;
    
$this->_i=0;
    
$this->_c=count($this->_d);
}

Constructor.

current() method
public mixed current()
{return} mixed the current array item
Source Code: framework/collections/CStackIterator.php#70 (show)
public function current()
{
    return 
$this->_d[$this->_i];
}

Returns the current array item. This method is required by the interface Iterator.

key() method
public integer key()
{return} integer the key of the current array item
Source Code: framework/collections/CStackIterator.php#60 (show)
public function key()
{
    return 
$this->_i;
}

Returns the key of the current array item. This method is required by the interface Iterator.

next() method
public void next()
Source Code: framework/collections/CStackIterator.php#79 (show)
public function next()
{
    
$this->_i++;
}

Moves the internal pointer to the next array item. This method is required by the interface Iterator.

rewind() method
public void rewind()
Source Code: framework/collections/CStackIterator.php#50 (show)
public function rewind()
{
    
$this->_i=0;
}

Rewinds internal array pointer. This method is required by the interface Iterator.

valid() method
public boolean valid()
{return} boolean
Source Code: framework/collections/CStackIterator.php#89 (show)
public function valid()
{
    return 
$this->_i<$this->_c;
}

Returns whether there is an item at current position. This method is required by the interface Iterator.

Be the first person to leave a comment

Please to leave your comment.