[ Index ]
 

Code source de PRADO 3.0.6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/framework/Collections/ -> TStack.php (sommaire)

TStack, TStackIterator classes

Author: Qiang Xue <qiang.xue@gmail.com>
Copyright: Copyright © 2005 PradoSoft
License: http://www.pradosoft.com/license/
Version: $Id: TStack.php 1397 2006-09-07 07:55:53Z wei $
Poids: 263 lignes (6 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 2 classes

TStack:: (11 méthodes):
  __construct()
  toArray()
  copyFrom()
  clear()
  contains()
  peek()
  pop()
  push()
  getIterator()
  getCount()
  count()

TStackIterator:: (6 méthodes):
  __construct()
  rewind()
  key()
  current()
  next()
  valid()


Classe: TStack  - X-Ref

TStack class

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,
<code>
foreach($stack as $item) ...
</code>

__construct($data=null)   X-Ref
Constructor.
Initializes the stack with an array or an iterable object.

param: array|Iterator the intial data. Default is null, meaning no initialization.

toArray()   X-Ref

return: array the list of items in stack

copyFrom($data)   X-Ref
Copies iterable data into the stack.
Note, existing data in the list will be cleared first.

param: mixed the data to be copied from, must be an array or object implementing Traversable

clear()   X-Ref
Removes all items in the stack.


contains($item)   X-Ref

param: mixed the item
return: boolean whether the stack contains the item

peek()   X-Ref
Returns the item at the top of the stack.
Unlike {@link pop()}, this method does not remove the item from the stack.

return: mixed item at the top of the stack

pop()   X-Ref
Pops up the item at the top of the stack.

return: mixed the item at the top of the stack

push($item)   X-Ref
Pushes an item into the stack.

param: mixed the item to be pushed into the stack

getIterator()   X-Ref
Returns an iterator for traversing the items in the stack.
This method is required by the interface IteratorAggregate.

return: Iterator an iterator for traversing the items in the stack.

getCount()   X-Ref

return: integer the number of items in the stack

count()   X-Ref
Returns the number of items in the stack.
This method is required by Countable interface.

return: integer number of items in the stack.

Classe: TStackIterator  - X-Ref

TStackIterator class

TStackIterator implements Iterator interface.

TStackIterator is used by TStack. It allows TStack to return a new iterator
for traversing the items in the list.

__construct(&$data)   X-Ref
Constructor.

param: array the data to be iterated through

rewind()   X-Ref
Rewinds internal array pointer.
This method is required by the interface Iterator.


key()   X-Ref
Returns the key of the current array item.
This method is required by the interface Iterator.

return: integer the key of the current array item

current()   X-Ref
Returns the current array item.
This method is required by the interface Iterator.

return: mixed the current array item

next()   X-Ref
Moves the internal pointer to the next array item.
This method is required by the interface Iterator.


valid()   X-Ref
Returns whether there is an item at current position.
This method is required by the interface Iterator.

return: boolean



Généré le : Sun Feb 25 21:07:04 2007 par Balluche grâce à PHPXref 0.7