![]() |
Documentación GVHIDRA 3.1.5
|
Métodos públicos | |
ListIterator (&$values) | |
hasNext () | |
hasPrevious () | |
next () | |
nextIndex () | |
previous () | |
previousIndex () | |
remove () | |
set ($value) | |
add ($value) | |
Campos de datos | |
$_values | |
$_index | |
$_element |
A ListIterator for lists that allows the programmer to traverse the list in either direction, modify the list during iteration, and obtain the iterator's current position in the list. A ListIterator has no current element; its cursor position always lies between the element that would be returned by a call to previous() and the element that would be returned by a call to next(). In a list of length n, there are n+1 valid index values, from 0 to n, inclusive.
Element(0) Element(1) Element(2) ... Element(n) ^ ^ ^ ^ ^ Index: 0 1 2 3 n+1
Note that the remove() and set() methods are not defined in terms of the cursor position; they are defined to operate on the last element returned by a call to next() or previous().
Definición en la línea 22 del archivo ListIterator.php.
add | ( | $ | value | ) |
Insert the specified element into the list.
public
mixed | $value |
Definición en la línea 151 del archivo ListIterator.php.
{ array_push($this->_values, $value); }
hasNext | ( | ) |
Check if the ListIterator has more elements when traversing the list in the forward direction.
public
Definición en la línea 59 del archivo ListIterator.php.
{
return ($this->_index < count($this->_values));
}
hasPrevious | ( | ) |
Check if the ListIterator has more elements when traversing the list in the reverse direction.
public
Definición en la línea 70 del archivo ListIterator.php.
{
return ($this->_index > 0);
}
ListIterator | ( | &$ | values | ) |
Create a ListIterator with the specified values.
public
array | $values |
Definición en la línea 43 del archivo ListIterator.php.
{ if (is_array($values)) { $this->_values = &$values; } else { $this->_values = array(); } $this->_element = $this->_index = 0; }
next | ( | ) |
Get the next element in the list.
public
Definición en la línea 80 del archivo ListIterator.php.
{ if ($this->hasNext()) { $value = $this->_values[$this->_index++]; $this->_element = $this->_index - 1; } return $value; }
nextIndex | ( | ) |
Get the index of the element that would be returned by a subsequent call to next().
public
Definición en la línea 95 del archivo ListIterator.php.
{
return $this->_index;
}
previous | ( | ) |
Get the previous element in the list.
public
Definición en la línea 105 del archivo ListIterator.php.
{ if ($this->hasPrevious()) { $value = $this->_values[--$this->_index]; $this->_element = $this->_index; } return $value; }
previousIndex | ( | ) |
Get the index of the element that would be returned by a subsequent call to prev().
public
Definición en la línea 120 del archivo ListIterator.php.
{
return ($this->_index - 1);
}
remove | ( | ) |
Remove from the list the last element that was returned by next() or previous().
public
Definición en la línea 130 del archivo ListIterator.php.
{ array_splice($this->_values, $this->_element, 1); }
set | ( | $ | value | ) |
Replace the last element returned by next() or previous() with the specified element.
public
mixed | $value |
Definición en la línea 141 del archivo ListIterator.php.
{ $this->_values[$this->_element] = $value; }
$_element |
Definición en la línea 35 del archivo ListIterator.php.
$_index |
Definición en la línea 31 del archivo ListIterator.php.
$_values |
Definición en la línea 27 del archivo ListIterator.php.