|
Class TStack
TStack class
TStack implements a stack.
The typical stack operations are implemented, which include TStack::push() ,
TStack::pop() and TStack::peek() . In addition, TStack::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 getCount Count property.
Items in the stack may be traversed using foreach as follows,
foreach($stack as $item) ...
-
TComponent
-
TStack
implements
IteratorAggregate,
Countable
Methods summary
public
|
#
__construct( array|Iterator $data = null )
Constructor. Initializes the stack with an array or an iterable object.
Constructor. Initializes the stack with an array or an iterable object.
Parameters
- $data
array|Iterator the initial data. Default is null, meaning no initialization.
Throws
Overrides
|
public
array
|
#
toArray( )
Returns
array the list of items in stack
|
public
|
#
copyFrom( mixed $data )
Copies iterable data into the stack. Note, existing data in the list will be
cleared first.
Copies iterable data into the stack. Note, existing data in the list will be
cleared first.
Parameters
- $data
mixed the data to be copied from, must be an array or object implementing Traversable
Throws
|
public
|
#
clear( )
Removes all items in the stack.
Removes all items in the stack.
|
public
boolean
|
#
contains( mixed $item )
Parameters
Returns
boolean whether the stack contains the item
|
public
mixed
|
#
peek( )
Returns the item at the top of the stack. Unlike TStack::pop() , this method
does not remove the item from the stack.
Returns the item at the top of the stack. Unlike TStack::pop() , this method
does not remove the item from the stack.
Returns
mixed item at the top of the stack
Throws
|
public
mixed
|
#
pop( )
Pops up the item at the top of the stack.
Pops up the item at the top of the stack.
Returns
mixed the item at the top of the stack
Throws
|
public
|
#
push( mixed $item )
Pushes an item into the stack.
Pushes an item into the stack.
Parameters
- $item
mixed the item to be pushed into the stack
|
public
Iterator
|
#
getIterator( )
Returns an iterator for traversing the items in the stack. This method is
required by the interface IteratorAggregate.
Returns an iterator for traversing the items in the stack. This method is
required by the interface IteratorAggregate.
Returns
Iterator an iterator for traversing the items in the stack.
Implementation of
IteratorAggregate::getIterator()
|
public
integer
|
#
getCount( )
Returns
integer the number of items in the stack
|
public
integer
|
#
count( )
Returns the number of items in the stack. This method is required by
Countable interface.
Returns the number of items in the stack. This method is required by
Countable interface.
Returns
integer number of items in the stack.
Implementation of
Countable::count()
|
Methods inherited from TComponent
__call(),
__destruct(),
__get(),
__isset(),
__set(),
__sleep(),
__unset(),
__wakeup(),
addParsedObject(),
asa(),
attachBehavior(),
attachBehaviors(),
attachClassBehavior(),
attachEventHandler(),
canGetProperty(),
canSetProperty(),
clearBehaviors(),
createdOnTemplate(),
detachBehavior(),
detachBehaviors(),
detachClassBehavior(),
detachEventHandler(),
disableBehavior(),
disableBehaviors(),
enableBehavior(),
enableBehaviors(),
evaluateExpression(),
evaluateStatements(),
fxAttachClassBehavior(),
fxDetachClassBehavior(),
getAutoGlobalListen(),
getBehaviorsEnabled(),
getClassHierarchy(),
getEventHandlers(),
getListeningToGlobalEvents(),
getSubProperty(),
hasEvent(),
hasEventHandler(),
hasProperty(),
isa(),
listen(),
raiseEvent(),
setSubProperty(),
unlisten()
|
|