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

<refentry xml:id="ds-deque.filter" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>Ds\Deque::filter</refname>
  <refpurpose>
    Creates a new deque using a <type>callable</type> to
    determine which values to include
 </refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>Ds\Deque</type><methodname>Ds\Deque::filter</methodname>
   <methodparam choice="opt"><type>callable</type><parameter>callback</parameter></methodparam>
  </methodsynopsis>
  <para>
    Creates a new deque using a <type>callable</type> to
    determine which values to include.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
 <variablelist>

    <varlistentry>
    <term><parameter>callback</parameter></term>

    <listitem>
        <para>
            <methodsynopsis xmlns="http://docbook.org/ns/docbook">
                <type>bool</type>
                <methodname><replaceable>callback</replaceable></methodname>
                <methodparam><type>mixed</type><parameter>value</parameter></methodparam>
            </methodsynopsis>
        </para>
        <para>
            Optional <type>callable</type> which returns &true; if the value should be included, &false; otherwise.
        </para>
        <para>
            If a callback is not provided, only values which are &true;
            (see <link linkend="language.types.boolean.casting">converting to boolean</link>)
            will be included.
        </para>
    </listitem>

   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
    A new deque containing all the values for which
    either the <parameter>callback</parameter> returned &true;, or all values that
    convert to &true; if a <parameter>callback</parameter> was not provided.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <example>
   <title><function>Ds\Deque::filter</function> example using callback function</title>
   <programlisting role="php">
<![CDATA[
<?php
$deque = new \Ds\Deque([1, 2, 3, 4, 5]);

var_dump($deque->filter(function($value) {
    return $value % 2 == 0;
}));
?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
object(Ds\Deque)#3 (2) {
  [0]=>
  int(2)
  [1]=>
  int(4)
}
]]>
   </screen>
  </example>
  <example>
   <title><function>Ds\Deque::filter</function> example without a callback function</title>
   <programlisting role="php">
<![CDATA[
<?php
$deque = new \Ds\Deque([0, 1, 'a', true, false]);

var_dump($deque->filter());
?>
]]>
   </programlisting>
   &example.outputs.similar;
   <screen>
<![CDATA[
object(Ds\Deque)#2 (3) {
  [0]=>
  int(1)
  [1]=>
  string(1) "a"
  [2]=>
  bool(true)
}
]]>
   </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
-->
