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
Afficher le fichier Open project: pradosoft/prado Class Usage Examples

Méthodes publiques

Méthode 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 méthode

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

clear() public méthode

Removes all items in the queue.
public clear ( )

contains() public méthode

public contains ( $item ) : boolean
Résultat boolean whether the queue contains the item

copyFrom() public méthode

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

count() public méthode

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

dequeue() public méthode

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

enqueue() public méthode

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

getCount() public méthode

public getCount ( ) : integer
Résultat integer the number of items in the queue

getIterator() public méthode

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

peek() public méthode

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

toArray() public méthode

public toArray ( ) : array
Résultat array the list of items in queue