/** * @depends testInsertGet */ function testRemove() { $map = new HashMap(); $map->set(0, 1); $map->remove(0); $this->assertCount(0, $map); $this->assertTrue($map->isEmpty()); }
public function testRemove() { // Remove the following lines when you implement this test. $this->assertTrue($this->object->remove(5)); $this->assertFalse($this->object->remove(99)); }
for ($f2 = 0; $f2 < $fnum; $f2++) { if ($cosmatrix[$f1][$f2] > $tempmax && $f1 != $f2 && $I[$f1] == 1 && $I[$f2] == 1) { // echo "YA"; $tempmax = $cosmatrix[$f1][$f2]; $maxf1 = $f1; $maxf2 = $f2; } } } //end search // echo "MAX1:$maxf1</br>";echo "MAX2:$maxf2</br>"; $c1 = $cluster->get($maxf1); $c2 = $cluster->get($maxf2); $c3 = array_merge($c1, $c2); asort($c3); $cluster->remove($maxf1); $cluster->remove($maxf2); $cluster->put($maxf1, $c3); $len1 = pow(count($HFlist->get($flist[$maxf1])), 0.5) + 1.0E-8; $len2 = pow(count($HFlist->get($flist[$maxf2])), 0.5) + 1.0E-8; for ($i = 0; $i < $fnum; $i++) { $cosmatrix[$maxf1][$i] = ($len1 * $cosmatrix[$maxf1][$i] + $len2 * $cosmatrix[$maxf2][$i]) / ($len1 + $len2); $cosmatrix[$i][$maxf1] = $cosmatrix[$maxf1][$i]; } $I[$maxf2] = 0; } //end round for*/ echo "R:{$round}</br>"; echo "MAX:{$tempmax}</br>"; $cid = $cluster->keys(); // print_r ($cid);
/** * This method tests that a exception is thrown if the * object with the key, passed to the remove method as * a parameter, does not exist in the HashMap. * * @return void */ public function testDeleteWithException() { // initialize a new HashMap $map = new HashMap(); // try to remove a not existing object from the HashMap try { $map->remove(1); $this->fail("Expect exception!"); } catch (\Exception $e) { $this->assertEquals("Index 1 out of bounds", $e->getMessage()); } }