Packages:
default
System
System.Caching
System.Collections
System.Data
System.Data.ActiveRecord
System.Data.ActiveRecord.Relations
System.Data.ActiveRecord.Scaffold
System.Data.ActiveReecord.Scaffold.InputBuilder
System.Data.Commom.Sqlite
System.Data.Common
System.Data.Common.Mssql
System.Data.Common.Mysql
System.Data.Common.Oracle
System.Data.Common.Pgsql
System.Data.Common.Sqlite
System.Data.DataGateway
System.Data.SqlMap
System.Data.SqlMap.Configuration
System.Data.SqlMap.Statements
System.Exceptions
System.I18N
System.IO
System.Security
System.Util
System.Web
System.Web.Services
System.Web.UI
System.Web.UI.ActiveControls
System.Web.UI.WebControls
System.Web.UI.WebControls.assets
System.Xml


Classes:
Keyword

Class TStack

TComponent
   |
   --TStack

TStack class

TStack implements a stack.

The typical stack operations are implemented, which include push(), pop() and peek(). In addition, 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 Count property.

Items in the stack may be traversed using foreach as follows,

  1. foreach($stack as $item) ...

Since: 3.0
Author: Qiang Xue <qiang.xue@gmail.com>

Constructor Summary
public
__construct Array
Constructor.

Method Summary
void
clear ()
Removes all items in the stack.
boolean
contains ( mixed $item)
void
copyFrom ( mixed $data)
Copies iterable data into the stack.
integer
count ()
Returns the number of items in the stack.
integer
Iterator
Returns an iterator for traversing the items in the stack.
mixed
peek ()
Returns the item at the top of the stack.
mixed
pop ()
Pops up the item at the top of the stack.
void
push ( mixed $item)
Pushes an item into the stack.
array
toArray ()
Methods Inherited From TComponent
TComponent::addParsedObject(), TComponent::attachEventHandler(), TComponent::canGetProperty(), TComponent::canSetProperty(), TComponent::createdOnTemplate(), TComponent::detachEventHandler(), TComponent::evaluateExpression(), TComponent::evaluateStatements(), TComponent::getEventHandlers(), TComponent::getSubProperty(), TComponent::hasEvent(), TComponent::hasEventHandler(), TComponent::hasProperty(), TComponent::raiseEvent(), TComponent::setSubProperty(), TComponent::__get(), TComponent::__set()

Constructor Details

__construct

public __construct Array

Constructor.

Initializes the stack with an array or an iterable object.

Throws: TInvalidDataTypeException If data is not null and neither an array nor an iterator.

Method Details

clear

public void clear ()

Removes all items in the stack.

Output
Exception

contains

public boolean contains (mixed $item )

Input
mixed$itemthe item
Output
boolean whether the stack contains the item
Exception

copyFrom

public void copyFrom (mixed $data )

Copies iterable data into the stack.

Note, existing data in the list will be cleared first.

Input
mixed$datathe data to be copied from, must be an array or object implementing Traversable
Output
Exception
throwsTInvalidDataTypeException If data is neither an array nor a Traversable.

count

public integer count ()

Returns the number of items in the stack.

This method is required by Countable interface.

Output
integer number of items in the stack.
Exception

getCount

public integer getCount ()

Output
integer the number of items in the stack
Exception

getIterator

public Iterator getIterator ()

Returns an iterator for traversing the items in the stack.

This method is required by the interface IteratorAggregate.

Output
Iterator an iterator for traversing the items in the stack.
Exception

peek

public mixed peek ()

Returns the item at the top of the stack.

Unlike pop(), this method does not remove the item from the stack.

Output
mixed item at the top of the stack
Exception
throwsTInvalidOperationException if the stack is empty

pop

public mixed pop ()

Pops up the item at the top of the stack.

Output
mixed the item at the top of the stack
Exception
throwsTInvalidOperationException if the stack is empty

push

public void push (mixed $item )

Pushes an item into the stack.

Input
mixed$itemthe item to be pushed into the stack
Output
Exception

toArray

public array toArray ()

Output
array the list of items in stack
Exception