ezcTreeNodeListIterator implements an iterator over an ezcTreeNodeList.
The iterator is instantiated with both an implementation of an ezcTree and an ezcTreeNodeList object. It can be used to iterate over all the nodes in a list.
Example:
Data for the nodes in the node lists is fetched on demand, unless the "prefetch" argument is set to true. In that case the iterator will fetch the data when the iterator is instantiated. This reduces the number of queries made for database and persistent object based data stores, but increases memory usage.
Example:
Source for this file: /Tree/src/tree_node_list_iterator.php
Version: | //autogentag// |
public ezcTreeNodeListIterator |
__construct(
$tree
, $nodeList
, [ $prefetch
= false] )
Constructs a new ezcTreeNodeListIterator object over $nodeList. |
public mixed |
current(
)
Returns the data belonging to the current node, and fetches the data in case on-demand fetching is required. |
public string |
key(
)
Returns the node ID of the current node. |
public void |
next(
)
Advances the internal pointer to the next node in the nodelist. |
public void |
rewind(
)
Rewinds the internal pointer back to the start of the nodelist. |
public bool |
valid(
)
Returns whether the internal pointer is still valid. |
Constructs a new ezcTreeNodeListIterator object over $nodeList.
The $tree argument is used so that data can be fetched on-demand.
Name | Type | Description |
---|---|---|
$tree |
ezcTree | |
$nodeList |
ezcTreeNodeList | |
$prefetch |
bool |
Returns the data belonging to the current node, and fetches the data in case on-demand fetching is required.
Method | Description |
---|---|
Iterator::current |
Returns the node ID of the current node.
Method | Description |
---|---|
Iterator::key |
Advances the internal pointer to the next node in the nodelist.
Method | Description |
---|---|
Iterator::next |
Rewinds the internal pointer back to the start of the nodelist.
Method | Description |
---|---|
Iterator::rewind |
Returns whether the internal pointer is still valid.
It returns false when the end of list has been reached.
Method | Description |
---|---|
Iterator::valid |