本文整理汇总了PHP中ArrayList::indexOf方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayList::indexOf方法的具体用法?PHP ArrayList::indexOf怎么用?PHP ArrayList::indexOf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayList
的用法示例。
在下文中一共展示了ArrayList::indexOf方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: removeObserver
public function removeObserver(MyObserver $o)
{
$i = $this->observers->indexOf($o);
if ($i >= 0) {
$this->observers->remove($i);
}
}
示例2: testSet
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);
}
示例3: indexOf
public function indexOf($value)
{
$this->validTypeThrow($value);
return parent::indexOf($value);
}
示例4: unset
// 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();