0 follower

CMapIterator

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

It allows CMap to return a new iterator for traversing the items in the map.

Public Methods

Hide inherited methods

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

Method Details

__construct() method
public void __construct(array &$data)
$data array the data to be iterated through
Source Code: framework/collections/CMapIterator.php#39 (show)
public function __construct(&$data)
{
    
$this->_d=&$data;
    
$this->_keys=array_keys($data);
    
$this->_key=reset($this->_keys);
}

Constructor.

current() method
public mixed current()
{return} mixed the current array element
Source Code: framework/collections/CMapIterator.php#73 (show)
public function current()
{
    return 
$this->_d[$this->_key];
}

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

key() method
public mixed key()
{return} mixed the key of the current array element
Source Code: framework/collections/CMapIterator.php#62 (show)
public function key()
{
    return 
$this->_key;
}

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

next() method
public void next()
Source Code: framework/collections/CMapIterator.php#83 (show)
public function next()
{
    
$this->_key=next($this->_keys);
}

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

rewind() method
public void rewind()
Source Code: framework/collections/CMapIterator.php#51 (show)
public function rewind()
{
    
$this->_key=reset($this->_keys);
}

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

valid() method
public boolean valid()
{return} boolean
Source Code: framework/collections/CMapIterator.php#94 (show)
public function valid()
{
    return 
$this->_key!==false;
}

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