PHP Class Prado\Collections\TQueue

TQueue implements a queue. The typical queue operations are implemented, which include {@link enqueue()}, {@link dequeue()} and {@link peek()}. In addition, {@link contains()} can be used to check if an item is contained in the queue. To obtain the number of the items in the queue, check the {@link getCount Count} property. Items in the queue may be traversed using foreach as follows, foreach($queue as $item) ...
Since: 3.1
Author: Qiang Xue ([email protected])
Author: Knut Urdalen ([email protected])
Inheritance: extends Prado\TComponent, implements IteratorAggregate, implements Countable
Mostrar archivo Open project: pradosoft/prado Class Usage Examples

Public Methods

Method Description
__construct ( $data = null ) Constructor.
clear ( ) Removes all items in the queue.
contains ( $item ) : boolean
copyFrom ( $data ) Copies iterable data into the queue.
count ( ) : integer Returns the number of items in the queue.
dequeue ( ) : mixed Removes and returns the object at the beginning of the queue.
enqueue ( $item ) Adds an object to the end of the queue.
getCount ( ) : integer
getIterator ( ) : Iterator Returns an iterator for traversing the items in the queue.
peek ( ) : mixed Returns the first item at the front of the queue.
toArray ( ) : array

Method Details

__construct() public method

Initializes the queue with an array or an iterable object.
public __construct ( $data = null )

clear() public method

Removes all items in the queue.
public clear ( )

contains() public method

public contains ( $item ) : boolean
return boolean whether the queue contains the item

copyFrom() public method

Note, existing data in the list will be cleared first.
public copyFrom ( $data )

count() public method

This method is required by \Countable interface.
public count ( ) : integer
return integer number of items in the queue.

dequeue() public method

Removes and returns the object at the beginning of the queue.
public dequeue ( ) : mixed
return mixed the item at the beginning of the queue

enqueue() public method

Adds an object to the end of the queue.
public enqueue ( $item )

getCount() public method

public getCount ( ) : integer
return integer the number of items in the queue

getIterator() public method

This method is required by the interface \IteratorAggregate.
public getIterator ( ) : Iterator
return Iterator an iterator for traversing the items in the queue.

peek() public method

Unlike {@link dequeue()}, this method does not remove the item from the queue.
public peek ( ) : mixed
return mixed item at the top of the queue

toArray() public method

public toArray ( ) : array
return array the list of items in queue