Stack::__construct

(Available since version 1.0)

Stack::__constructConstructs a new stack implemented using a singly linked list

Description

public Stack::__construct ( void )

This constructs a new empty stack.

Parameters

This function has no parameters.

Return Values

No value is returned.

Examples

Example #1 Stack::__construct() example

<?php
require 'vendor/autoload.php'// A PSR-4 or PSR-0 autoloader
use SEIDS\LinkedLists\Singly\Stack;

$s = new Stack();

$s->push(1);
$s->push(2);
$s->push(3);

while (!
$s->isEmpty())  {
 echo 
$s->pop()."\n";
}
?>

The above example will output:

3
2
1

To Top