• PHP Video Tutorials

PHP - Stack class Functions


A Stack is a “last in, first-out” or “LIFO” collection that can allow only access to the value at the top of structure and iterate in that order destructively. This class can use Ds\Vector internally.

Class synopsis

Ds\Stack implements Ds\Collection {
   /* Methods */
   public void allocate( int $capacity )
   public int capacity( void )
   public void clear( void )
   public Ds\Stack copy( void )
   public bool isEmpty( void )
   public mixed peek( void )
   public mixed pop( void )
   public void push([ mixed $...values ] )
   public array toArray( void )
}
Sr.No Functions & Description
1

Ds\Stack::copy() Function

This function can return a shallow copy of the stack.

2

Ds\Stack::count() Function

This function can be used to count the number of elements present in a stack.

3

Ds\Stack::isEmpty() Function

This function can return whether the stack is empty.

4

Ds\Stack::jsonSerialize() Function

This function can return the representation that can be converted to JSON.

5

Ds\Stack::peek() Function

This function can return the value at the top of a stack.

6

Ds\Stack::pop() Function

This function can remove and return the value at the top of a stack.

7

Ds\Stack::push() Function

This function can push the values onto a stack.

8

Ds\Stack::toArray() Function

This function can convert the stack to an array.

php_function_reference.htm
Advertisements