« Ds\Set::__construct
Ds\Set::copy »

Ds\Set::contains

(PECL ds >= 1.0.0)

Ds\Set::contains — Determines if the set contains all values

説明

public function Ds\Set::contains(mixed ...$values): bool

Determines if the set contains all values.

注意:

Values of type object are supported. If an object implements Ds\Hashable, equality will be determined by the object's equals function. If an object does not implement Ds\Hashable, objects must be references to the same instance to be considered equal.

警告

All comparisons are strict (type and value).

パラメータ

values

Values to check.

戻り値

false if any of the provided values are not in the set, true otherwise.

例

例1 Ds\Set::contains() example

<?php
$set = new \Ds\Set([1, 2, 3]);

var_dump($set->contains(1));                // true
var_dump($set->contains(1, 2));             // true
var_dump($set->contains(...[1, 2]));        // true

var_dump($set->contains("1"));              // false
var_dump($set->contains(...[1, 2, 3, 4]));  // false

var_dump($set->contains(...[]));            // true
?>

上の例の出力は、 たとえば以下のようになります。

bool(true)
bool(true)
bool(true)
bool(false)
bool(false)
bool(true)
関連キーワード:
contains   values   dump   Determines   Values   type   Hashable   construct   copy   mixed   supported   implements   equality   determined   equals   implement   objects   references   instance   considered   equal   comparisons   strict   check   provided
関連する関数・ページ:
ds-vector.contains   ds-sequence.contains   ds-deque.contains   ds-map.hasvalue   ds-map.haskey   class.ds-set