当前位置: 首页>>代码示例>>PHP>>正文


PHP Set::contains方法代码示例

本文整理汇总了PHP中Set::contains方法的典型用法代码示例。如果您正苦于以下问题:PHP Set::contains方法的具体用法?PHP Set::contains怎么用?PHP Set::contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Set的用法示例。


在下文中一共展示了Set::contains方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCreate

 public function testCreate()
 {
     $set = new Set(['a', 'b']);
     $this->assertTrue($set->contains('a'));
     $this->assertTrue($set->contains('b'));
     $this->assertFalse($set->contains('c'));
     $this->assertEquals(['a', 'b'], $set->toArray());
 }
开发者ID:jesseschalken,项目名称:php-set,代码行数:8,代码来源:SetTest.php

示例2: is_subset

 public function is_subset(Set $other)
 {
     foreach ($this as $item) {
         if (!$other->contains($item)) {
             return false;
         }
     }
     return true;
 }
开发者ID:thumbtack,项目名称:crankshaft,代码行数:9,代码来源:Set.php

示例3: intersect

 /**
  * @param Set $other
  * A set of items to intersect with this set
  *
  * @return Set
  * A new set which contains only items in this
  * Set and the given Set
  */
 public function intersect(Set $other) : Set
 {
     $set = new Set();
     foreach ($this as $element) {
         if ($other->contains($element)) {
             $set->attach($element);
         }
     }
     return $set;
 }
开发者ID:actank,项目名称:phan,代码行数:18,代码来源:Set.php

示例4: testContains

 /**
  * testContains method
  *
  * @return void
  */
 public function testContains()
 {
     $a = array(0 => array('name' => 'main'), 1 => array('name' => 'about'));
     $b = array(0 => array('name' => 'main'), 1 => array('name' => 'about'), 2 => array('name' => 'contact'), 'a' => 'b');
     $this->assertTrue(Set::contains($a, $a));
     $this->assertFalse(Set::contains($a, $b));
     $this->assertTrue(Set::contains($b, $a));
 }
开发者ID:mrbadao,项目名称:api-official,代码行数:13,代码来源:SetTest.php

示例5: contains

 /**
  * Determines if one Set or array contains the exact keys and values of another.
  *
  * @param array $val1 First value
  * @param array $val2 Second value
  * @return boolean true if $val1 contains $val2, false otherwise
  * @link http://book.cakephp.org/2.0/en/core-utility-libraries/set.html#Set::contains
  */
 public static function contains($val1, $val2 = null)
 {
     if (empty($val1) || empty($val2)) {
         return false;
     }
     foreach ($val2 as $key => $val) {
         if (is_numeric($key)) {
             Set::contains($val, $val1);
         } else {
             if (!isset($val1[$key]) || $val1[$key] != $val) {
                 return false;
             }
         }
     }
     return true;
 }
开发者ID:aichelman,项目名称:StudyUp,代码行数:24,代码来源:Set.php

示例6: testContainsAnEmptySet

 public function testContainsAnEmptySet()
 {
     $generator = new Set($this->singleElementGenerator);
     $this->assertTrue($generator->contains([]));
 }
开发者ID:nicoder,项目名称:eris,代码行数:5,代码来源:SetTest.php

示例7: contains

 /**
  * Checks if the collection contains the given element.
  * 
  * @param mixed $value
  * @param bool $strict Use a strict comparison (===) if TRUE
  */
 public function contains($value, $strict = false)
 {
     if ($this->guard !== null) {
         $this->guard->checkMemberGuard(new GuardPermission(__FUNCTION__, 'call'));
     }
     return $this->set->contains($value, $strict);
 }
开发者ID:bahrmichael,项目名称:eyeos,代码行数:13,代码来源:collection.php

示例8: Set

    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
// readonly collection
echo "Construct as readonly\n";
$set2 = new Set($arr);
$set2->freeze();
Debug::dump($set2->isFrozen());
try {
    echo "Adding Jack\n";
    Debug::dump($set2->append($jack));
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
try {
    echo "Removing Jack\n";
    $set2->remove($jack);
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
try {
    echo "Clearing\n";
    $set2->clear();
} catch (Exception $e) {
    echo get_class($e), ': ', $e->getMessage(), "\n\n";
}
foreach ($set2 as $key => &$val) {
    $val = FALSE;
}
echo "Contains Jack?\n";
Debug::dump($set2->contains($jack));
开发者ID:vrana,项目名称:nette,代码行数:30,代码来源:test.Set.php


注:本文中的Set::contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。