<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->

<refentry xml:id="ds-map.union" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>Ds\Map::union</refname>
  <refpurpose>Creates a new map using values from the current instance and another map</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>Ds\Map</type><methodname>Ds\Map::union</methodname>
   <methodparam><type>Ds\Map</type><parameter>map</parameter></methodparam>
  </methodsynopsis>
  <para>
    Creates a new map that contains the pairs of the current instance as well as the
    pairs of another <parameter>map</parameter>.
  </para>
  <para>
    <code>A ∪ B = {x: x ∈ A ∨ x ∈ B}</code>
  </para>

  <note>
    <para>
        Values of the current instance will be overwritten by those provided where keys are equal.
    </para>
  </note>

 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <variablelist>
   <varlistentry>
    <term><parameter>map</parameter></term>
    <listitem>
     <para>
        The other map, to combine with the current instance.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
    <para>
    A new map containing all the pairs of the current instance as well as another <parameter>map</parameter>.
    </para>
 </refsect1>

 <refsect1 role="seealso">
  &reftitle.seealso;
  <para>
   <simplelist>
    <member><link xlink:href="https://en.wikipedia.org/wiki/Union_(set_theory)">Union</link> on Wikipedia</member>
   </simplelist>
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>Ds\Map::union</function> example</title>
   <programlisting role="php">
<![CDATA[
<?php
$a = new \Ds\Map(["a" => 1, "b" => 2, "c" => 3]);
$b = new \Ds\Map(["b" => 3, "c" => 4, "d" => 5]);

print_r($a->union($b));
?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
Ds\Map Object
(
    [0] => Ds\Pair Object
        (
            [key] => a
            [value] => 1
        )

    [1] => Ds\Pair Object
        (
            [key] => b
            [value] => 3
        )

    [2] => Ds\Pair Object
        (
            [key] => c
            [value] => 4
        )

    [3] => Ds\Pair Object
        (
            [key] => d
            [value] => 5
        )

)
]]>
   </screen>
  </example>
 </refsect1>


</refentry>

<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
