LinkedList::__construct

(Available since version 1.0)

LinkedList::__constructConstructs a new singly linked list

Description

public LinkedList::__construct ( void )

This constructs a new empty singly linked list.

Parameters

This function has no parameters.

Return Values

No value is returned.

Examples

Example #1 LinkedList::__construct() example

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

$sll = new LinkedList();

$sll->push(2);
$sll->push(3);
$sll->unshift(5);

foreach(
$sll as $item) echo $item."\n";
?>

The above example will output:

5
2
3

To Top