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
Extended by Cake\Collection\Collection implements Cake\Collection\CollectionInterface, Serializable uses Cake\Collection\CollectionTrait
Extended by Cake\Collection\Iterator\BufferedIterator implements Countable, Serializable

Properties summary

  • $_buffer protected
    SplDoublyLinkedList
    The in-memory cache containing results from previous iterators
  • $_current protected
    mixed
    Last record fetched from the inner iterator
  • $_finished protected
    boolean
    Whether or not the internal iterator has reached its end.
  • $_index protected
    integer
    Points to the next record number that should be fetched
  • $_key protected
    mixed
    Last key obtained from the inner iterator
  • $_started protected
    boolean

    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()source 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

InvalidArgumentException
If passed incorrect type for items.

Overrides

Cake\Collection\Collection::__construct()

count()source public

count( )

Returns the number or items in this collection

Returns

integer

Throws

LogicException

Overrides

Cake\Collection\Collection::count()

Implementation of

Countable::count()

current()source public

current( )

Returns the current record in the iterator

Returns

mixed

Overrides

IteratorIterator::current()

key()source public

key( )

Returns the current key in the iterator

Returns

mixed

Overrides

IteratorIterator::key()

next()source public

next( )

Advances the iterator pointer to the next element

Overrides

IteratorIterator::next()

rewind()source public

rewind( )

Rewinds the collection

Overrides

IteratorIterator::rewind()

serialize()source public

serialize( )

Returns a string representation of this object that can be used to reconstruct it

Returns

string

Overrides

Cake\Collection\Collection::serialize()

Implementation of

Serializable::serialize()

unserialize()source public

unserialize( string $buffer )

Unserializes the passed string and rebuilds the BufferedIterator instance

Parameters

string $buffer
The serialized buffer iterator

Overrides

Cake\Collection\Collection::unserialize()

Implementation of

Serializable::unserialize()

valid()source public

valid( )

Returns whether or not the iterator has more elements

Returns

boolean

Overrides

IteratorIterator::valid()

Methods inherited from Cake\Collection\Collection

__debugInfo()source public

__debugInfo( )

Returns an array that can be used to describe the internal state of this object.

Returns

array

Methods used from Cake\Collection\CollectionTrait

_unwrap()source public

_unwrap( )

Backwards compatible wrapper for unwrap()

Deprecated

Returns

Iterator

append()source public

append( $items )

buffered()source public

buffered( )

Returns

Cake\Collection\Iterator\BufferedIterator

cartesianProduct()source public

cartesianProduct( callable $operation null , callable $filter null )

Returns

Cake\Collection\CollectionInterface

chunk()source public

chunk( $chunkSize )

combine()source public

combine( $keyPath , $valuePath , $groupPath null )

compile()source public

compile( $preserveKeys true )

contains()source public

contains( $value )

countBy()source public

countBy( $callback )

each()source public

each( callable $c )

every()source public

every( callable $c )

extract()source public

extract( $matcher )

filter()source public

filter( callable $c null )

Returns

Cake\Collection\Iterator\FilterIterator

first()source public

first( )

firstMatch()source public

firstMatch( array $conditions )

groupBy()source public

groupBy( $callback )

indexBy()source public

indexBy( $callback )

insert()source public

insert( $path , $values )

Returns

Cake\Collection\Iterator\InsertIterator

isEmpty()source public

isEmpty( )

jsonSerialize()source public

jsonSerialize( )

last()source public

last( )

listNested()source public

listNested( $dir 'desc' , $nestingKey 'children' )

Returns

Cake\Collection\Iterator\TreeIterator

map()source public

map( callable $c )

Returns

Cake\Collection\Iterator\ReplaceIterator

match()source public

match( array $conditions )

max()source public

max( $callback , $type SORT_NUMERIC )

min()source public

min( $callback , $type SORT_NUMERIC )

nest()source public

nest( $idPath , $parentPath , $nestingKey 'children' )

reduce()source public

reduce( callable $c , $zero null )

reject()source public

reject( callable $c )

Returns

Cake\Collection\Iterator\FilterIterator

sample()source public

sample( $size 10 )

shuffle()source public

shuffle( )

skip()source public

skip( $howMany )

some()source public

some( callable $c )

sortBy()source public

sortBy( $callback , $dir SORT_DESC , $type SORT_NUMERIC )

stopWhen()source public

stopWhen( $condition )

Returns

Cake\Collection\Iterator\StoppableIterator

sumOf()source public

sumOf( $matcher null )

take()source public

take( $size 1 , $from 0 )

through()source public

through( callable $handler )

toArray()source public

toArray( $preserveKeys true )

toList()source public

toList( )

transpose()source public

transpose( )

Returns

Cake\Collection\CollectionInterface

unfold()source public

unfold( callable $transformer null )

unwrap()source public

unwrap( )

zip()source public

zip( $items )

zipWith()source public

zipWith( $items , $callable )

Properties detail

$_buffersource

protected SplDoublyLinkedList

The in-memory cache containing results from previous iterators

$_currentsource

protected mixed

Last record fetched from the inner iterator

$_finishedsource

protected boolean

Whether or not the internal iterator has reached its end.

false

$_indexsource

protected integer

Points to the next record number that should be fetched

$_keysource

protected mixed

Last key obtained from the inner iterator

$_startedsource

protected boolean

Whether or not the internal iterator's rewind method was already called

false

© 2005–2017 The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/3.3/class-Cake.Collection.Iterator.BufferedIterator.html