Class BufferedIterator
Creates an iterator from another iterator that will keep the results of the inner iterator in memory, so that results don't have to be re-calculated.
- IteratorIterator implements Iterator, Traversable, OuterIterator
- Cake\Collection\Collection implements Cake\Collection\CollectionInterface, Serializable uses Cake\Collection\CollectionTrait
- Cake\Collection\Iterator\BufferedIterator implements Countable, Serializable
Properties summary
-
$_buffer
protectedSplDoublyLinkedList
The in-memory cache containing results from previous iterators -
$_current
protectedmixed
Last record fetched from the inner iterator -
$_finished
protectedboolean
Whether or not the internal iterator has reached its end. -
$_index
protectedinteger
Points to the next record number that should be fetched -
$_key
protectedmixed
Last key obtained from the inner iterator -
$_started
protectedboolean
Whether or not the internal iterator's rewind method was already called
Method Summary
-
__construct() public
Maintains an in-memory cache of the results yielded by the internal iterator.
-
count() public
Returns the number or items in this collection -
current() public
Returns the current record in the iterator -
key() public
Returns the current key in the iterator -
next() public
Advances the iterator pointer to the next element -
rewind() public
Rewinds the collection -
serialize() public
Returns a string representation of this object that can be used to reconstruct it
-
unserialize() public
Unserializes the passed string and rebuilds the BufferedIterator instance -
valid() public
Returns whether or not the iterator has more elements
Method Detail
__construct() public ¶
__construct( array|Traversable $items )
Maintains an in-memory cache of the results yielded by the internal iterator.
Parameters
- array|Traversable $items
- The items to be filtered.
Throws
If passed incorrect type for items.
Overrides
count() public ¶
count( )
Returns the number or items in this collection
Returns
Overrides
Implementation of
Countable::count()
current() public ¶
current( )
Returns the current record in the iterator
Returns
Overrides
IteratorIterator::current()
key() public ¶
key( )
Returns the current key in the iterator
Returns
Overrides
IteratorIterator::key()
next() public ¶
next( )
Advances the iterator pointer to the next element
Overrides
IteratorIterator::next()
serialize() public ¶
serialize( )
Returns a string representation of this object that can be used to reconstruct it
Returns
Overrides
Implementation of
Serializable::serialize()
unserialize() public ¶
unserialize( string $buffer )
Unserializes the passed string and rebuilds the BufferedIterator instance
Parameters
- string $buffer
- The serialized buffer iterator
Overrides
Implementation of
Serializable::unserialize()
Methods inherited from Cake\Collection\Collection
__debugInfo() public ¶
__debugInfo( )
Returns an array that can be used to describe the internal state of this object.
Returns
countKeys() public ¶
countKeys( )
Returns the number of unique keys in this iterator. This is, the number of
elements the collection will contain after calling toArray()
Returns
Implementation of
Methods used from Cake\Collection\CollectionTrait
cartesianProduct() public ¶
cartesianProduct( callable $operation null , callable $filter null )
Parameters
- callable $operation optional null
- Operation
- callable $filter optional null
- Filter
Returns
Throws
optimizeUnwrap() protected ¶
optimizeUnwrap( )
Unwraps this iterator and returns the simplest traversable that can be used for getting the data out
Returns
Magic methods inherited from Cake\Collection\CollectionInterface
cartesianProduct()
|