本文整理汇总了PHP中ArrayList::contains方法的典型用法代码示例。如果您正苦于以下问题:PHP ArrayList::contains方法的具体用法?PHP ArrayList::contains怎么用?PHP ArrayList::contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ArrayList
的用法示例。
在下文中一共展示了ArrayList::contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddInvalidElement
function testAddInvalidElement()
{
$list = new ArrayList("string");
$this->expectException("IllegalArgumentException");
$list->add(1223);
$this->assertFalse($list->contains("Hello there"));
}
示例2: contains
public function contains($value)
{
$this->validTypeThrow($value);
return parent::contains($value);
}
示例3: testContains
public function testContains()
{
// Remove the following lines when you implement this test.
$this->assertTrue($this->object->contains(5));
$this->assertFalse($this->object->contains(9999));
}
示例4: insertAt
echo "Adding Larry using insertAt()\n";
Debug::dump($list->insertAt(0, $larry));
echo "Adding Larry using insertAt()\n";
Debug::dump($list->insertAt(4, $larry));
try {
echo "Adding Larry using insertAt()\n";
Debug::dump($list->insertAt(6, $larry));
} catch (Exception $e) {
echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
// (array) IList
echo "(array):\n";
Debug::dump((array) $list);
// IList::contains
echo "Contains Jack?\n";
Debug::dump($list->contains($jack));
echo "Contains Mary?\n";
Debug::dump($list->contains($mary));
try {
echo "Contains foo?\n";
Debug::dump($list->contains($foo));
} catch (Exception $e) {
echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
// IList::offsetExists
echo "Contains #-1?\n";
Debug::dump(isset($list[-1]));
echo "Contains #0?\n";
Debug::dump(isset($list[0]));
echo "Contains #5?\n";
Debug::dump(isset($list[5]));