PHP Класс 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) ...
С версии: 3.0
Автор: Qiang Xue ([email protected])
Наследование: extends Prado\TComponent, implements IteratorAggregate, implements Countable
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
__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

Описание методов

__construct() публичный Метод

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

clear() публичный Метод

Removes all items in the stack.
public clear ( )

contains() публичный Метод

public contains ( $item ) : boolean
Результат boolean whether the stack contains the item

copyFrom() публичный Метод

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

count() публичный Метод

This method is required by \Countable interface.
public count ( ) : integer
Результат integer number of items in the stack.

getCount() публичный Метод

public getCount ( ) : integer
Результат integer the number of items in the stack

getIterator() публичный Метод

This method is required by the interface \IteratorAggregate.
public getIterator ( ) : Iterator
Результат Iterator an iterator for traversing the items in the stack.

peek() публичный Метод

Unlike {@link pop()}, this method does not remove the item from the stack.
public peek ( ) : mixed
Результат mixed item at the top of the stack

pop() публичный Метод

Pops up the item at the top of the stack.
public pop ( ) : mixed
Результат mixed the item at the top of the stack

push() публичный Метод

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

toArray() публичный Метод

public toArray ( ) : array
Результат array the list of items in stack