phrame web development platform
download  | documentation  | resources  | credits 


 


Phrame Example: Util classes

This is a short example of how to use the Util classes.

  • ArrayList
  • HashMap
  • ListIterator
  • Object
  • Stack

<?php
//create new list passing elements in constructor
$list = new ArrayList(array(123453));
//create new empty list and add elements manually
$list2 = new ArrayList();
$list2->add('one');
$list2->add('two');
$list2->add('three');
//add all the elements from list2 to list
$list->addAll($list2);
//remove range of elements from list
$list->removeRange(13);
//get list iterator to populate map
$iterator $list->listIterator();
//create new empty map
$map = new HashMap();
while (
$iterator->hasNext()) {
    
//put key/value pair from list into map
    
$map->put($iterator->nextIndex(), $iterator->next());
}
//manually put more key/value pairs in map
$map->put('four'4);
$map->put('five'5);
$map->put('six'6);
//create new map passing key/value pair in constructor
$map2 = new HashMap(array('one' => 'uno'));
//clone map to map3
$map3 $map->clone();
//create new stack with values from map3
$stack = new Stack($map3->values());
//manually push another value onto stack
$stack->push('seven');
//display the result
echo '<pre>'.$stack->toString().'</pre>';
?>

That completes the short example of how to use the Util classes.


 

software development Software Development
Copyright © 2002 Texas Tech University
All rights reserved.
Last modified: November 19 2002 16:47:22

SourceForge Logo