Login   Register  
PHP Classes
elePHPant
Icontem

File: demo/linkedlistdemo.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Ordland  >  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: 2013-04-08 04:50
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);     
?>