Login   Register  
PHP Classes
elePHPant
Icontem

File: demo/hashsetdemo.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/hashsetdemo.php  >  Download  
File: demo/hashsetdemo.php
Role: Example script
Content type: text/plain
Description: A demo using HashSet
Class: PHP Collections Framework
Manipulate collections of objects like Java and C#
Author: By
Last change:
Date: 2013-04-08 04:49
Size: 986 bytes
 

Contents

Class file image Download
<?php

require "autoloader.php";
use 
Resource\Native\String as String;
use 
Resource\Collection\HashSet as HashSet;
use 
Resource\Collection\LinkedHashSet as LinkedHashSet;

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

$set = new HashSet;
$set->add($mithos);
$set->add($martel);
$set->add($yuan);
$set->add($kratos);
//$set->add(2);

$iterator $set->iterator();
echo 
"HashSet Test<br>";
while(
$iterator->hasNext()){
    echo 
$iterator->next();
    echo 
"<br>";
}
echo 
"<br>";
//var_dump($set);

$set2 = new LinkedHashSet;
$set2->add($mithos);
$set2->add($martel);
$set2->add($yuan);
$set2->add($kratos);

$iterator2 $set2->iterator();
echo 
"LinkedHashSet Test<br>";
while(
$iterator2->hasNext()){
    echo 
$iterator2->next();
    echo 
"<br>";
}
echo 
"<br>";
//var_dump($set2);
?>