Location: PHPKode > projects > PHP Object Oriented Framework > poof/Stack.class.php
    This file is part of POOF.

    POOF is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.
    POOF is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    GNU General Public License for more details.
    You should have received a copy of the GNU General Public License
    along with POOF; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

* A stack data structure. A stack is a LIFO (Last In First Out) data structure.
* @package poof
* @author Brian Takita <hide@address.com>
* @version 0.4
class Stack {
    * @var mixed The top element in the Stack.
    var $top = null;
    * @var array The Stack data.
    * @access private
    var $_stack = array();
    * Push the argument onto the stack.
    * @param mixed $element The element to be pushed onto the stack.
    function push($element) {
        array_push($this->_stack, &$element);
    * Pop the Stack.
    * @returns mixed The reference to the popped element.
    function &pop() {
        $element = &$this->top();
        return $element;
    * Get the lenght of the Stack.
    * @returns int The lenght of the Stack.
    function get_length() {
        return count($this->_stack);
Return current item: PHP Object Oriented Framework