Counter
in package
implements
Iterator
Class \Hoa\Iterator\Counter.
A counter.
Tags
Table of Contents
Interfaces
- Iterator
- Interface \Hoa\Iterator.
Properties
- $_from : int
- From (lower bound).
- $_i : int
- Current index.
- $_key : int
- Current key.
- $_step : int
- Step.
- $_to : int
- To (upper bound).
Methods
- __construct() : mixed
- Constructor.
- current() : int
- Return the current element.
- key() : int
- Return the key of the current element.
- next() : void
- Move forward to next element.
- rewind() : void
- Rewind the iterator to the first element.
- valid() : bool
- Check if current position is valid.
Properties
$_from
From (lower bound).
protected
int
$_from
= 0
$_i
Current index.
protected
int
$_i
= 0
$_key
Current key.
protected
int
$_key
= 0
$_step
Step.
protected
int
$_step
= 0
$_to
To (upper bound).
protected
int
$_to
= 0
Methods
__construct()
Constructor.
public
__construct(int $from, int $to, int $step) : mixed
Equivalent to: for($i = $from; $i < $to; $i += $step)
Parameters
- $from : int
-
Start value.
- $to : int
-
Maximum value.
- $step : int
-
Step.
Tags
current()
Return the current element.
public
current() : int
Return values
intkey()
Return the key of the current element.
public
key() : int
Return values
intnext()
Move forward to next element.
public
next() : void
rewind()
Rewind the iterator to the first element.
public
rewind() : void
valid()
Check if current position is valid.
public
valid() : bool