PHP Classes

File: demo/linkedlistdemo.php

Recommend this page to a friend!
  Classes of Ordland Euroboros   PHP Collections Framework   demo/linkedlistdemo.php   Download  
File: demo/linkedlistdemo.php
Role: Example script
Content type: text/plain
Description: A demo using LinkedList
Class: PHP Collections Framework
Manipulate collections of objects like Java and C#
Author: By
Last change:
Date: 10 years ago
Size: 1,012 bytes
 

Contents

Class file image Download
<?php

require "autoloader.php";
use
Resource\Native\String as String;
use
Resource\Collection\ArrayList as ArrayList;
use
Resource\Collection\LinkedList as LinkedList;

$mithos = new String("Mithos Yggdrasill");
$martel = new String("Martel Yggdrasill");
$yuan = new String("Yuan Ka-Fei");
$kratos = new String("Kratos Aurion");
$remiel = new String("Remiel");

$arrayList = new ArrayList(5);
$arrayList->add(new String("Pronyma"));
$arrayList->add(new String("Forcystus"));
$arrayList->add(new String("Rodyle"));
$arrayList->add(new String("Kvar"));
$arrayList->add(new String("Magnius"));

$linkedList = new LinkedList;
$linkedList->offerFirst($mithos);
$linkedList->offerLast($martel);
$linkedList->offerLast($yuan);
$linkedList->offerLast($kratos);

$iterator = $linkedList->iterator();
$iterator->add($martel);

while(
$iterator->hasNext()){
    echo
$iterator->next();
    echo
"<br>";
}

//echo $linkedList->indexOf($mithos);
//echo $linkedList->indexOf($yuan);
?>