public function removeObserver(MyObserver $o) { $i = $this->observers->indexOf($o); if ($i >= 0) { $this->observers->remove($i); } }
public function testSet() { // Remove the following lines when you implement this test. $this->assertTrue($this->object->set(2, 69)->toNative() == 2); $this->assertTrue($this->object->get(2)->toNative() == 69); $this->assertTrue($this->object->indexOf(69) == 2); }
public function indexOf($value) { $this->validTypeThrow($value); return parent::indexOf($value); }
// IList::offsetUnset try { echo "Removing using unset\n"; unset($list[-1]); } catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } try { echo "Removing using unset\n"; unset($list[1]); } catch (Exception $e) { echo get_class($e), ': ', $e->getMessage(), "\n\n"; } // IList::indexOf() echo "indexOf Jack:\n"; Debug::dump($list->indexOf($jack)); echo "indexOf Mary:\n"; Debug::dump($list->indexOf($mary)); // IList::count echo "Count: ", $list->count(), "\n"; echo "Count: ", count($list), "\n"; // IList::getIterator echo "Get Interator:\n"; foreach ($list as $key => $person) { echo $key, ' => ', $person->sayHi(); } // IList::clear echo "Clearing\n"; $list->clear(); foreach ($list as $person) { $person->sayHi();