Sgss_Collection_Array_Stack
Represents a LIFO queued collection array

Description

Class diagram:
Sgss_Collection_Stack_Abstract
 + Sgss_Collection_Array_Stack
Author:
Matsuda Shota
Copyright:
(c) 2007-2008 Matsuda Shota
License:
http://creativecommons.org/licenses/GPL/2.0/
Located in:
/Collection/Array/Stack.php (line 46)

Class overview

Variables

protected array $_elements

Elements in this queue

protected int $_max

Maximum number of elements

protected int $_size

The number of elements in this stack

Methods

__construct ([int|null $max = null])

The constructor

mixed|null peek ()

Retrieves the element at the top of this stack without removing it

mixed|null pop ()

Retrieves and removes the element at the top of this stack

boolean push (mixed $element)

Pushes the specified element at the top of this stack

int size ()

Returns the number of elements in this stack

Inherited from Sgss_Collection_Stack_Abstract:
count(), current(), isEmpty(), key(), next(), rewind(), valid()

Variable detail

$_elements 

Elements in this queue

Signature:
protected array $_elements


$_max 

Maximum number of elements

Signature:
protected int $_max = 0x7fffffff


$_size 

The number of elements in this stack

Signature:
protected int $_size = 0


Method detail

__construct

The constructor

Parameters:
  • int|null $max

    Maximum number of elements

Signature:
public __construct ([int|null $max = null])


peek

Retrieves the element at the top of this stack without removing it

Returns:
mixed|null -- Retrieved element, or null if this stack contains no element
Related subject:
Sgss_Collection_Stack_Interface::peek()
Signature:
public mixed|null peek ()


pop

Retrieves and removes the element at the top of this stack

Returns:
mixed|null -- Retrieved element, or null if this stack contains no element
Related subject:
Sgss_Collection_Stack_Interface::pop()
Signature:
public mixed|null pop ()


push

Pushes the specified element at the top of this stack

Parameters:
  • mixed $element

    Element to be pushed

Returns:
boolean -- True when the element was pushed to this stack
Related subject:
Sgss_Collection_Stack_Interface::push()
Signature:
public boolean push (mixed $element)


size

Returns the number of elements in this stack

Returns:
int -- The number of elements in this stack
Related subject:
Sgss_Collection_Stack_Interface::size()
Signature:
public int size ()