Login   Register  
PHP Classes
elePHPant
Icontem

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

Contents

Class file image Download
<?php

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

$mithosKey = new String("Mithos Yggdrasill");
$martelKey = new String("Martel Yggdrasill");
$yuanKey = new String("Yuan Ka-fei");
$kratosKey = new String("Kratos Aurion");
$remielKey = new String("Remiel");

$mithosValue = new String("Leader of Cruxis");
$martelValue = new String("Mithos' Older Sister");
$yuanValue = new String("Leader of Renegades");
$kratosValue = new String("One of Four Seraphim");
$remielValue = new String("Minion of Cruxis");

$map = new LinkedHashMap;
$map->put($mithosKey$mithosValue);
$map->put($martelKey$martelValue);
$map->put($yuanKey$yuanValue);
$map->put($kratosKey$kratosValue);
$map->put($remielKey$remielValue);

$iterator $map->iterator();
while(
$iterator->hasNext()){
    
$entry $iterator->nextEntry();
    echo 
"{$entry->getKey()}{$entry->getValue()}<br>";
}

echo 
$map->get($mithosKey);
echo 
"<br>";
echo 
$map->get($martelKey);

/*
$map->clear();
var_dump($map);
var_dump($map->containsValue($remielKey));
var_dump($map->containsValue($remielValue));
*/
?>