Exemple #1
0
 /**
  * @depends   testInit
  * @return    HashMap
  */
 public function testSet(HashMap $hashMapObject)
 {
     $this->assertEquals($hashMapObject->set(self::$mapKey[0], self::$mapValue[0]), self::$mapValue[0]);
     $this->assertEquals($hashMapObject->set(self::$mapKey[1], self::$mapValue[1]), self::$mapValue[1]);
     $this->assertEquals($hashMapObject->set(self::$mapKey[2], self::$mapValue[2]), self::$mapValue[2]);
     return $hashMapObject;
 }
Exemple #2
0
// init hash map
$hashMapObject = new HashMap();
// mapping pair 1
$mapKey[] = new FooString('Key A');
$mapValue[] = new FooString('Value A');
// mapping pair 2
$mapKey[] = new FooString('Key B');
$mapValue[] = new FooString('Value B');
// mapping pair 3
$mapKey[] = new FooString('Key C');
$mapValue[] = new FooString('Value C');
// mapping pair 4
$mapKey[] = new FooString('Key D');
$mapValue[] = new FooString('Value D');
// set 3 mappings to map
$hashMapObject->set($mapKey[0], $mapValue[0]);
$hashMapObject->set($mapKey[1], $mapValue[1]);
$hashMapObject->set($mapKey[2], $mapValue[2]);
// get 3 mappings from map
echo $hashMapObject->get($mapKey[0]);
// 'Value A'
echo $hashMapObject->get($mapKey[1]);
// 'Value B'
echo $hashMapObject->get($mapKey[2]);
// 'Value C'
echo '<br/>';
// count mappings
echo count($hashMapObject);
// 3
// remove mapping with String 'Value B'
$hashMapObject->remove($mapKey[1]);