« Ds\Map::count
Ds\Map::filter »

Ds\Map::diff

(PECL ds >= 1.0.0)

Ds\Map::diff — Creates a new map using keys that aren't in another map

説明

public function Ds\Map::diff(Ds\Map $map): Ds\Map

Returns the result of removing all keys from the current instance that are present in a given map.

A \ B = {x ∈ A | x ∉ B}

パラメータ

map

The map containing the keys to exclude in the resulting map.

戻り値

The result of removing all keys from the current instance that are present in a given map.

参考

例

例1 Ds\Map::diff() example

<?php
$a = new \Ds\Map(["a" => 1, "b" => 2, "c" => 3]);
$b = new \Ds\Map(["b" => 4, "c" => 5, "d" => 6]);

var_dump($a->diff($b));
?>

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

object(Ds\Map)#3 (1) {
  [0]=>
  object(Ds\Pair)#4 (2) {
    ["key"]=>
    string(1) "a"
    ["value"]=>
    int(1)
  }
}
関連キーワード:
keys   diff   Creates   using   aren't   removing   current   instance   present   given   count   filter   aren   containing   exclude   resulting   参考   Complement   Wikipedia   example   dump   Pair
関連する関数・ページ:
ds-set.diff   ds-map.xor   ds-map.keys   ds-map.intersect   function.rnp-load-keys   function.rnp-import-keys