PHP Class Prado\Collections\TStack

TStack implements a stack. The typical stack operations are implemented, which include {@link push()}, {@link pop()} and {@link peek()}. In addition, {@link contains()} can be used to check if an item is contained in the stack. To obtain the number of the items in the stack, check the {@link getCount Count} property. Items in the stack may be traversed using foreach as follows, foreach($stack as $item) ...
Since: 3.0
Author: Qiang Xue ([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 stack.
contains ( $item ) : boolean
copyFrom ( $data ) Copies iterable data into the stack.
count ( ) : integer Returns the number of items in the stack.
getCount ( ) : integer
getIterator ( ) : Iterator Returns an iterator for traversing the items in the stack.
peek ( ) : mixed Returns the item at the top of the stack.
pop ( ) : mixed Pops up the item at the top of the stack.
push ( $item ) Pushes an item into the stack.
toArray ( ) : array

Method Details

__construct() public méthode

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

clear() public méthode

Removes all items in the stack.
public clear ( )

contains() public méthode

public contains ( $item ) : boolean
Résultat boolean whether the stack 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 stack.

getCount() public méthode

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

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 stack.

peek() public méthode

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

pop() public méthode

Pops up the item at the top of the stack.
public pop ( ) : mixed
Résultat mixed the item at the top of the stack

push() public méthode

Pushes an item into the stack.
public push ( $item )

toArray() public méthode

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