mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
Add missing method synopsis for ds extension
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@339774 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
345e07d0f8
commit
9e924f5b82
112 changed files with 6368 additions and 326 deletions
|
@ -14,10 +14,10 @@
|
|||
<methodparam><type>int</type><parameter>capacity</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Ensures that enough memory is allocated for a required capacity.
|
||||
This removes the need to reallocate the internal as values are added.
|
||||
Ensures that enough memory is allocated for a required capacity.
|
||||
This removes the need to reallocate the internal as values are added.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
|
@ -29,12 +29,16 @@
|
|||
The number of values for which capacity should be allocated.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Capacity will always be rounded up to the nearest power of 2.
|
||||
Capacity will be halved if element count drops below a quarter of
|
||||
current capacity.
|
||||
</para>
|
||||
<para>
|
||||
Capacity will stay the same if this value is less than or equal to the
|
||||
current capacity.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
Capacity will always be rounded up to the nearest power of 2.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
@ -47,6 +51,32 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::allocate</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque();
|
||||
var_dump($deque->capacity());
|
||||
|
||||
$deque->allocate(100);
|
||||
var_dump($deque->capacity());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(8)
|
||||
int(128)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,84 @@
|
|||
<refentry xml:id="ds-deque.apply" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::apply</refname>
|
||||
<refpurpose>Applies a callback to each value.</refpurpose>
|
||||
<refpurpose>Updates all values by applying a callback function to each value.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::apply</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::apply</methodname>
|
||||
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Updates all values by applying a <parameter>callback</parameter> function to
|
||||
each value in the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>callback</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<methodsynopsis xmlns="http://docbook.org/ns/docbook">
|
||||
<type>mixed</type>
|
||||
<methodname><replaceable>callback</replaceable></methodname>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</para>
|
||||
<para>
|
||||
A <type>callable</type> to apply to each value in the deque.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The callback should return what the value should be replaced by.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::apply</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
$deque->apply(function($value) { return $value * 2; });
|
||||
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 2
|
||||
[1] => 4
|
||||
[2] => 6
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,54 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::capacity</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>int</type><methodname>Ds\Deque::capacity</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the current capacity.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The current capacity.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::capacity</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque();
|
||||
var_dump($deque->capacity());
|
||||
|
||||
$deque->push(...range(1, 50));
|
||||
var_dump($deque->capacity());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(8)
|
||||
int(64)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,65 @@
|
|||
<refentry xml:id="ds-deque.clear" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::clear</refname>
|
||||
<refpurpose>Removes all values.</refpurpose>
|
||||
<refpurpose>Removes all values from the deque.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::clear</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::clear</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes all values from the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::clear</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
print_r($deque);
|
||||
|
||||
$deque->clear();
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,81 @@
|
|||
<refentry xml:id="ds-deque.contains" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::contains</refname>
|
||||
<refpurpose>Determines if the sequence contains all given values.</refpurpose>
|
||||
<refpurpose>Determines if the deque contains given values.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::contains</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Deque::contains</methodname>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>...values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Determines if the deque contains all values.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Values to check.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&false; if any of the provided <parameter>values</parameter> are not in the
|
||||
deque, &true; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::contains</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(['a', 'b', 'c', 1, 2, 3]);
|
||||
|
||||
var_dump($deque->contains('a')); // true
|
||||
var_dump($deque->contains('a', 'b')); // true
|
||||
var_dump($deque->contains('c', 'd')); // false
|
||||
|
||||
var_dump($deque->contains(...['c', 'b', 'a'])); // true
|
||||
|
||||
// Always strict
|
||||
var_dump($deque->contains(1)); // true
|
||||
var_dump($deque->contains('1')); // false
|
||||
|
||||
var_dump($sequece->contains(...[])); // true
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
93
reference/ds/ds/deque/copy.xml
Normal file
93
reference/ds/ds/deque/copy.xml
Normal file
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-deque.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::copy</refname>
|
||||
<refpurpose>Returns a shallow copy of the deque.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Deque</type><methodname>Ds\Deque::copy</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a shallow copy of the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
A shallow copy of the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Deque([1, 2, 3]);
|
||||
$b = $a->copy();
|
||||
|
||||
$b->push(4);
|
||||
|
||||
print_r($a);
|
||||
print_r($b);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
[3] => 4
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
|
@ -5,16 +5,116 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Deque::filter</refname>
|
||||
<refpurpose>
|
||||
Creates a copy using a <type>callable</type> to determine which values to include.
|
||||
Creates a new deque using a <type>callable</type> to
|
||||
determine which values to include.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::filter</function>
|
||||
</para>
|
||||
&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
|
||||
|
|
|
@ -10,11 +10,72 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::find</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Deque::find</methodname>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the index of the <parameter>value</parameter>, or &false; if not found.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>value</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The value to find.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The index of the value, or &false; if not found.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Values will be compared by value and by type.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::find</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", 1, true]);
|
||||
|
||||
var_dump($deque->find("a")); // 0
|
||||
var_dump($deque->find("b")); // false
|
||||
var_dump($deque->find("1")); // false
|
||||
var_dump($deque->find(1)); // 1
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(1)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,61 @@
|
|||
<refentry xml:id="ds-deque.first" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::first</refname>
|
||||
<refpurpose>Returns the first value.</refpurpose>
|
||||
<refpurpose>Returns the first value in the deque.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::first</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Deque::first</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the first value in the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The first value in the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>UnderflowException</classname> if empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::first</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
var_dump($deque->first());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(1)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,94 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::get</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Deque::get</methodname>
|
||||
<methodparam><type>int</type><parameter>index</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the value at a given index.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>index</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The index to access, starting at 0.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The value at the requested index.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>OutOfRangeException</classname> if the index is not valid.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::get</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c"]);
|
||||
|
||||
var_dump($deque->get(0));
|
||||
var_dump($deque->get(1));
|
||||
var_dump($deque->get(2));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(1) "a"
|
||||
string(1) "b"
|
||||
string(1) "c"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Deque::get</function> example using array syntax</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c"]);
|
||||
|
||||
var_dump($deque[0]);
|
||||
var_dump($deque[1]);
|
||||
var_dump($deque[2]);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(1) "a"
|
||||
string(1) "b"
|
||||
string(1) "c"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,103 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::insert</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::insert</methodname>
|
||||
<methodparam><type>int</type><parameter>index</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>...values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Inserts values into the deque at a given index.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>index</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The index at which to insert. <code>0 <= index <= count</code>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
You can insert at the index equal to the number of values.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The value or values to insert.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>OutOfRangeException</classname> if the index is not valid.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::insert</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque();
|
||||
|
||||
$deque->insert(0, "e"); // [e]
|
||||
$deque->insert(1, "f"); // [e, f]
|
||||
$deque->insert(2, "g"); // [e, f, g]
|
||||
$deque->insert(0, "a", "b"); // [a, b, e, f, g]
|
||||
$deque->insert(2, ...["c", "d"]); // [a, b, c, d, e, f, g]
|
||||
|
||||
var_dump($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Deque)#1 (7) {
|
||||
[0]=>
|
||||
string(1) "a"
|
||||
[1]=>
|
||||
string(1) "b"
|
||||
[2]=>
|
||||
string(1) "c"
|
||||
[3]=>
|
||||
string(1) "d"
|
||||
[4]=>
|
||||
string(1) "e"
|
||||
[5]=>
|
||||
string(1) "f"
|
||||
[6]=>
|
||||
string(1) "g"
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,58 @@
|
|||
<refentry xml:id="ds-deque.isempty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::isEmpty</refname>
|
||||
<refpurpose>Returns whether the instance is empty.</refpurpose>
|
||||
<refpurpose>Returns whether the deque is empty</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::isEmpty</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Deque::isEmpty</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns whether the deque is empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns &true; if the deque is empty, &false; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::isEmpty</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Deque([1, 2, 3]);
|
||||
$b = new \Ds\Deque();
|
||||
|
||||
var_dump($a->isEmpty());
|
||||
var_dump($b->isEmpty());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,78 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::join</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>string</type><methodname>Ds\Deque::join</methodname>
|
||||
<methodparam choice="opt"><type>string</type><parameter>glue</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Joins all values together as a string using an optional separator between each value.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>glue</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An optional string to separate each value.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
All values of the deque joined together as a string.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::join</function> example using a separator string</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c", 1, 2, 3]);
|
||||
|
||||
var_dump($deque->join("|"));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(11) "a|b|c|1|2|3"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Deque::join</function> example without a separator string</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c", 1, 2, 3]);
|
||||
|
||||
var_dump($deque->join());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(11) "abc123"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -7,12 +7,58 @@
|
|||
<refpurpose>Returns the last value.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::last</function>
|
||||
</para>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Deque::last</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the last value in the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The last value in the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>UnderflowException</classname> if empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::last</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
var_dump($deque->last());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(3)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,92 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::map</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Deque</type><methodname>Ds\Deque::map</methodname>
|
||||
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the result of applying a <parameter>callback</parameter> function to
|
||||
each value in the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>callback</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<methodsynopsis xmlns="http://docbook.org/ns/docbook">
|
||||
<type>mixed</type>
|
||||
<methodname><replaceable>callback</replaceable></methodname>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</para>
|
||||
<para>
|
||||
A <type>callable</type> to apply to each value in the deque.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The callable should return what the new value will be in the new deque.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The result of applying a <parameter>callback</parameter> to each value in
|
||||
the deque.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
The values of the current instance won't be affected.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::map</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
|
||||
print_r($deque->map(function($value) { return $value * 2; }));
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 2
|
||||
[1] => 4
|
||||
[2] => 6
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,93 @@
|
|||
<refentry xml:id="ds-deque.merge" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::merge</refname>
|
||||
<refpurpose>Returns the result of adding all given values.</refpurpose>
|
||||
<refpurpose>Returns the result of adding all given values to the deque.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::merge</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Deque</type><methodname>Ds\Deque::merge</methodname>
|
||||
<methodparam><type>mixed</type><parameter>values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the result of adding all given values to the deque.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A <classname>traversable</classname> object or an &array;.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The result of adding all given values to the deque,
|
||||
effectively the same as adding the values to a copy, then returning that copy.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
The current instance won't be affected.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::merge</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
|
||||
var_dump($deque->merge([4, 5, 6]));
|
||||
var_dump($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Deque)#2 (6) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[3]=>
|
||||
int(4)
|
||||
[4]=>
|
||||
int(5)
|
||||
[5]=>
|
||||
int(6)
|
||||
}
|
||||
object(Ds\Deque)#1 (3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,63 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::pop</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Deque::pop</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes and returns the last value.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The removed last value.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>UnderflowException</classname> if empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::pop</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
|
||||
var_dump($deque->pop());
|
||||
var_dump($deque->pop());
|
||||
var_dump($deque->pop());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(3)
|
||||
int(2)
|
||||
int(1)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,78 @@
|
|||
<refentry xml:id="ds-deque.push" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::push</refname>
|
||||
<refpurpose>Adds values to the end of the sequence.</refpurpose>
|
||||
<refpurpose>Adds values to the end of the deque.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::push</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::push</methodname>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>...values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Adds values to the end of the deque.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The values to add.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::push</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque();
|
||||
|
||||
$deque->push("a");
|
||||
$deque->push("b");
|
||||
$deque->push("c", "d");
|
||||
$deque->push(...["e", "f"]);
|
||||
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => a
|
||||
[1] => b
|
||||
[2] => c
|
||||
[3] => d
|
||||
[4] => e
|
||||
[5] => f
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,137 @@
|
|||
<refentry xml:id="ds-deque.reduce" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::reduce</refname>
|
||||
<refpurpose>Reduces the sequence to a single value using a callback function.</refpurpose>
|
||||
<refpurpose>Reduces the deque to a single value using a callback function.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::reduce</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Deque::reduce</methodname>
|
||||
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>initial</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Reduces the deque to a single value using a callback function.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>callback</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type><methodname><replaceable>callback</replaceable></methodname>
|
||||
<methodparam><type>mixed</type><parameter>carry</parameter></methodparam>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>carry</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The return value of the previous callback, or <parameter>initial</parameter> if
|
||||
it's the first iteration.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>value</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The value of the current iteration.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</listitem>
|
||||
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>initial</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The initial value of the carry value. Can be &null;.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The return value of the final callback.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::reduce</function> with initial value example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
|
||||
$callback = function($carry, $value) {
|
||||
return $carry * $value;
|
||||
};
|
||||
|
||||
var_dump($deque->reduce($callback, 5));
|
||||
|
||||
// Iterations:
|
||||
//
|
||||
// $carry = $initial = 5
|
||||
//
|
||||
// $carry = $carry * 1 = 5
|
||||
// $carry = $carry * 2 = 10
|
||||
// $carry = $carry * 3 = 30
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(30)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Deque::reduce</function> without an initial value example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
|
||||
var_dump($deque->reduce(function($carry, $value) {
|
||||
return $carry + $value + 5;
|
||||
}));
|
||||
|
||||
// Iterations:
|
||||
//
|
||||
// $carry = $initial = null
|
||||
//
|
||||
// $carry = $carry + 1 + 5 = 6
|
||||
// $carry = $carry + 2 + 5 = 13
|
||||
// $carry = $carry + 3 + 5 = 21
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(21)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,72 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::remove</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Deque::remove</methodname>
|
||||
<methodparam><type>int</type><parameter>index</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes and returns a value by index.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>index</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The index of the value to remove.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The value that was removed.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>OutOfRangeException</classname> if the index is not valid.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::remove</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c"]);
|
||||
|
||||
var_dump($deque->remove(1));
|
||||
var_dump($deque->remove(0));
|
||||
var_dump($deque->remove(0));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(1) "b"
|
||||
string(1) "a"
|
||||
string(1) "c"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -5,16 +5,63 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Deque::reverse</refname>
|
||||
<refpurpose>
|
||||
Reverses the sequence in-place.
|
||||
Reverses the deque in-place.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::reverse</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::reverse</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Reverses the deque in-place.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::reverse</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c"]);
|
||||
$deque->reverse();
|
||||
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => c
|
||||
[1] => b
|
||||
[2] => a
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,70 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::reversed</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Deque</type><methodname>Ds\Deque::reversed</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a reversed copy of the deque.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
A reversed copy of the deque.
|
||||
|
||||
<note>
|
||||
<para>
|
||||
The current instance is not affected.
|
||||
</para>
|
||||
</note>
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::reversed</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c"]);
|
||||
|
||||
print_r($deque->reversed());
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => c
|
||||
[1] => b
|
||||
[2] => a
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => a
|
||||
[1] => b
|
||||
[2] => c
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,83 @@
|
|||
<refentry xml:id="ds-deque.rotate" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::rotate</refname>
|
||||
<refpurpose>Rotates the sequence by a given number of rotations.</refpurpose>
|
||||
<refpurpose>Rotates the deque by a given number of rotations.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::rotate</methodname>
|
||||
<methodparam><type>int</type><parameter>rotations</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
See <function>Ds\Sequence::rotate</function>
|
||||
Rotates the deque by a given number of rotations, which is equivalent
|
||||
to successively calling <code>$deque->push($deque->shift())</code> if the number
|
||||
of rotations is positive, or <code>$deque->unshift($deque->pop())</code> if negative.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>rotations</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The number of times the deque should be rotated.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;. The deque of the current instance will be rotated.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::rotate</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c", "d"]);
|
||||
|
||||
$deque->rotate(1); // "a" is shifted, then pushed.
|
||||
print_r($deque);
|
||||
|
||||
$deque->rotate(2); // "b" and "c" are both shifted, the pushed.
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
(
|
||||
[0] => b
|
||||
[1] => c
|
||||
[2] => d
|
||||
[3] => a
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => d
|
||||
[1] => a
|
||||
[2] => b
|
||||
[3] => c
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -7,12 +7,107 @@
|
|||
<refpurpose>Updates a value at a given index.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::set</methodname>
|
||||
<methodparam><type>int</type><parameter>index</parameter></methodparam>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Updates a value at a given index.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>index</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The index of the value to update.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>value</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The new value.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
See <function>Ds\Sequence::set</function>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>OutOfRangeException</classname> if the index is not valid.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::set</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c"]);
|
||||
|
||||
$deque->set(1, "_");
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => a
|
||||
[1] => _
|
||||
[2] => c
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Deque::set</function> example using array syntax</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c"]);
|
||||
|
||||
$deque[1] = "_";
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => a
|
||||
[1] => _
|
||||
[2] => c
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -8,9 +8,60 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::shift</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Deque::shift</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes and returns the first value.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The first value, which was removed.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>UnderflowException</classname> if empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::shift</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c"]);
|
||||
|
||||
var_dump($deque->shift());
|
||||
var_dump($deque->shift());
|
||||
var_dump($deque->shift());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(1) "a"
|
||||
string(1) "b"
|
||||
string(1) "c"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -5,14 +5,130 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Deque::slice</refname>
|
||||
<refpurpose>
|
||||
Returns a sub-sequence of a given range.
|
||||
Returns a sub-deque of a given range.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::slice</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Deque</type><methodname>Ds\Deque::slice</methodname>
|
||||
<methodparam><type>int</type><parameter>index</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>array</type><parameter>length</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Creates a sub-deque of a given range.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>index</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The index at which the sub-deque starts.
|
||||
</para>
|
||||
<para>
|
||||
If positive, the deque will start at that index in the deque.
|
||||
If negative, the deque will start that far from the end.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>length</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
If a length is given and is positive, the resulting
|
||||
deque will have up to that many values in it.
|
||||
|
||||
If the length results in an overflow, only
|
||||
values up to the end of the deque will be included.
|
||||
|
||||
If a length is given and is negative, the deque
|
||||
will stop that many values from the end.
|
||||
|
||||
If a length is not provided, the resulting deque
|
||||
will contain all values between the index and the
|
||||
end of the deque.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
A sub-deque of the given range.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::slice</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque(["a", "b", "c", "d", "e"]);
|
||||
|
||||
// Slice from 2 onwards
|
||||
print_r($deque->slice(2));
|
||||
|
||||
// Slice from 1, for a length of 3
|
||||
print_r($deque->slice(1, 3));
|
||||
|
||||
// Slice from 1 onwards
|
||||
print_r($deque->slice(1));
|
||||
|
||||
// Slice from 2 from the end onwards
|
||||
print_r($deque->slice(-2));
|
||||
|
||||
// Slice from 1 to 1 from the end
|
||||
print_r($deque->slice(1, -1));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => c
|
||||
[1] => d
|
||||
[2] => e
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => b
|
||||
[1] => c
|
||||
[2] => d
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => b
|
||||
[1] => c
|
||||
[2] => d
|
||||
[3] => e
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => d
|
||||
[1] => e
|
||||
)
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => b
|
||||
[1] => c
|
||||
[2] => d
|
||||
)
|
||||
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -5,14 +5,111 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Deque::sort</refname>
|
||||
<refpurpose>
|
||||
Sorts the sequence in-place.
|
||||
Sorts the deque in-place.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::sort</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::sort</methodname>
|
||||
<methodparam choice="opt"><type>callable</type><parameter>comparator</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Sorts the deque in-place, using an optional <parameter>comparator</parameter> function.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>comparator</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
&return.callbacksort;
|
||||
</para>
|
||||
&callback.cmp;
|
||||
<caution>
|
||||
<para>
|
||||
Returning <emphasis>non-integer</emphasis> values from the comparison
|
||||
function, such as <type>float</type>, will result in an internal cast to
|
||||
<type>integer</type> of the callback's return value. So values such as
|
||||
0.99 and 0.1 will both be cast to an integer value of 0, which will
|
||||
compare such values as equal.
|
||||
</para>
|
||||
</caution>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::sort</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([4, 5, 1, 3, 2]);
|
||||
$deque->sort();
|
||||
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
[3] => 4
|
||||
[4] => 5
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Deque::sort</function> example using a comparator</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([4, 5, 1, 3, 2]);
|
||||
|
||||
$deque->sort(function($a, $b) {
|
||||
return $b <=> $a;
|
||||
});
|
||||
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 5
|
||||
[1] => 4
|
||||
[2] => 3
|
||||
[3] => 2
|
||||
[4] => 1
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -8,9 +8,105 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::sorted</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Deque</type><methodname>Ds\Deque::sorted</methodname>
|
||||
<methodparam choice="opt"><type>callable</type><parameter>comparator</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a sorted copy, using an optional <parameter>comparator</parameter> function.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>comparator</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
&return.callbacksort;
|
||||
</para>
|
||||
&callback.cmp;
|
||||
<caution>
|
||||
<para>
|
||||
Returning <emphasis>non-integer</emphasis> values from the comparison
|
||||
function, such as <type>float</type>, will result in an internal cast to
|
||||
<type>integer</type> of the callback's return value. So values such as
|
||||
0.99 and 0.1 will both be cast to an integer value of 0, which will
|
||||
compare such values as equal.
|
||||
</para>
|
||||
</caution>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a sorted copy of the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::sorted</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([4, 5, 1, 3, 2]);
|
||||
|
||||
print_r($deque->sorted());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
[3] => 4
|
||||
[4] => 5
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Deque::sorted</function> example using a comparator</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([4, 5, 1, 3, 2]);
|
||||
|
||||
$sorted = $deque->sorted(function($a, $b) {
|
||||
return $b <=> $a;
|
||||
});
|
||||
|
||||
print_r($sorted);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => 5
|
||||
[1] => 4
|
||||
[2] => 3
|
||||
[3] => 2
|
||||
[4] => 1
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -4,13 +4,75 @@
|
|||
<refentry xml:id="ds-deque.sum" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::sum</refname>
|
||||
<refpurpose>Returns the sum of all values in the sequence.</refpurpose>
|
||||
<refpurpose>Returns the sum of all values in the deque.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>number</type><methodname>Ds\Deque::sum</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the sum of all values in the deque.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
See <function>Ds\Sequence::sum</function>
|
||||
Arrays and objects are considered equal to zero when calculating the sum.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The sum of all the values in the deque as either a <type>float</type> or <type>int</type>
|
||||
depending on the values in the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::sum</function> integer example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
var_dump($deque->sum());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(6)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Deque::sum</function> float example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2.5, 3]);
|
||||
var_dump($deque->sum());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
float(6.5)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -5,14 +5,66 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Deque::toArray</refname>
|
||||
<refpurpose>
|
||||
Converts the instance to an &array;.
|
||||
Converts the deque to an &array;.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>array</type><methodname>Ds\Deque::toArray</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Converts the deque to an &array;.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
See <function>Ds\Collection::toArray</function>
|
||||
Casting to an &array; is not supported yet.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
An &array; containing all the values in the same order as the deque.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::toArray</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
|
||||
var_dump($deque->toArray());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -4,13 +4,80 @@
|
|||
<refentry xml:id="ds-deque.unshift" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Deque::unshift</refname>
|
||||
<refpurpose>Adds values to the front of the sequence.</refpurpose>
|
||||
<refpurpose>Adds values to the front of the deque.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::unshift</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Deque::unshift</methodname>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Adds values to the front of the deque, moving all the current
|
||||
values forward to make room for the new values.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The values to add to the front of the deque.
|
||||
<note>
|
||||
<para>
|
||||
Multiple values will be added in the same order that they are
|
||||
passed.
|
||||
</para>
|
||||
</note>
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Deque::unshift</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$deque = new \Ds\Deque([1, 2, 3]);
|
||||
|
||||
$deque->unshift("a");
|
||||
$deque->unshift("b", "c");
|
||||
|
||||
print_r($deque);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Deque Object
|
||||
(
|
||||
[0] => b
|
||||
[1] => c
|
||||
[2] => a
|
||||
[3] => 1
|
||||
[4] => 2
|
||||
[5] => 3
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
</refentry>
|
||||
|
|
4
reference/ds/ds/entities.collection.xml
Normal file
4
reference/ds/ds/entities.collection.xml
Normal file
|
@ -0,0 +1,4 @@
|
|||
&reference.ds.ds.collection.clear;
|
||||
&reference.ds.ds.collection.copy;
|
||||
&reference.ds.ds.collection.isempty;
|
||||
&reference.ds.ds.collection.toarray;
|
31
reference/ds/ds/entities.deque.xml
Normal file
31
reference/ds/ds/entities.deque.xml
Normal file
|
@ -0,0 +1,31 @@
|
|||
&reference.ds.ds.deque.allocate;
|
||||
&reference.ds.ds.deque.apply;
|
||||
&reference.ds.ds.deque.capacity;
|
||||
&reference.ds.ds.deque.clear;
|
||||
&reference.ds.ds.deque.contains;
|
||||
&reference.ds.ds.deque.copy;
|
||||
&reference.ds.ds.deque.filter;
|
||||
&reference.ds.ds.deque.find;
|
||||
&reference.ds.ds.deque.first;
|
||||
&reference.ds.ds.deque.get;
|
||||
&reference.ds.ds.deque.insert;
|
||||
&reference.ds.ds.deque.isempty;
|
||||
&reference.ds.ds.deque.join;
|
||||
&reference.ds.ds.deque.last;
|
||||
&reference.ds.ds.deque.map;
|
||||
&reference.ds.ds.deque.merge;
|
||||
&reference.ds.ds.deque.pop;
|
||||
&reference.ds.ds.deque.push;
|
||||
&reference.ds.ds.deque.reduce;
|
||||
&reference.ds.ds.deque.remove;
|
||||
&reference.ds.ds.deque.reverse;
|
||||
&reference.ds.ds.deque.reversed;
|
||||
&reference.ds.ds.deque.rotate;
|
||||
&reference.ds.ds.deque.set;
|
||||
&reference.ds.ds.deque.shift;
|
||||
&reference.ds.ds.deque.slice;
|
||||
&reference.ds.ds.deque.sort;
|
||||
&reference.ds.ds.deque.sorted;
|
||||
&reference.ds.ds.deque.sum;
|
||||
&reference.ds.ds.deque.toarray;
|
||||
&reference.ds.ds.deque.unshift;
|
2
reference/ds/ds/entities.hashable.xml
Normal file
2
reference/ds/ds/entities.hashable.xml
Normal file
|
@ -0,0 +1,2 @@
|
|||
&reference.ds.ds.hashable.equals;
|
||||
&reference.ds.ds.hashable.hash;
|
37
reference/ds/ds/entities.map.xml
Normal file
37
reference/ds/ds/entities.map.xml
Normal file
|
@ -0,0 +1,37 @@
|
|||
&reference.ds.ds.map.allocate;
|
||||
&reference.ds.ds.map.apply;
|
||||
&reference.ds.ds.map.capacity;
|
||||
&reference.ds.ds.map.clear;
|
||||
&reference.ds.ds.map.construct;
|
||||
&reference.ds.ds.map.copy;
|
||||
&reference.ds.ds.map.count;
|
||||
&reference.ds.ds.map.diff;
|
||||
&reference.ds.ds.map.filter;
|
||||
&reference.ds.ds.map.first;
|
||||
&reference.ds.ds.map.get;
|
||||
&reference.ds.ds.map.haskey;
|
||||
&reference.ds.ds.map.hasvalue;
|
||||
&reference.ds.ds.map.intersect;
|
||||
&reference.ds.ds.map.isempty;
|
||||
&reference.ds.ds.map.keys;
|
||||
&reference.ds.ds.map.ksort;
|
||||
&reference.ds.ds.map.ksorted;
|
||||
&reference.ds.ds.map.last;
|
||||
&reference.ds.ds.map.map;
|
||||
&reference.ds.ds.map.merge;
|
||||
&reference.ds.ds.map.pairs;
|
||||
&reference.ds.ds.map.put;
|
||||
&reference.ds.ds.map.putAll;
|
||||
&reference.ds.ds.map.reduce;
|
||||
&reference.ds.ds.map.remove;
|
||||
&reference.ds.ds.map.reverse;
|
||||
&reference.ds.ds.map.reversed;
|
||||
&reference.ds.ds.map.skip;
|
||||
&reference.ds.ds.map.slice;
|
||||
&reference.ds.ds.map.sort;
|
||||
&reference.ds.ds.map.sorted;
|
||||
&reference.ds.ds.map.sum;
|
||||
&reference.ds.ds.map.toarray;
|
||||
&reference.ds.ds.map.union;
|
||||
&reference.ds.ds.map.values;
|
||||
&reference.ds.ds.map.xor;
|
6
reference/ds/ds/entities.pair.xml
Normal file
6
reference/ds/ds/entities.pair.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
&reference.ds.ds.pair.clear;
|
||||
&reference.ds.ds.pair.construct;
|
||||
&reference.ds.ds.pair.copy;
|
||||
&reference.ds.ds.pair.isempty;
|
||||
&reference.ds.ds.pair.jsonserialize;
|
||||
&reference.ds.ds.pair.toarray;
|
11
reference/ds/ds/entities.priorityqueue.xml
Normal file
11
reference/ds/ds/entities.priorityqueue.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
&reference.ds.ds.priorityqueue.allocate;
|
||||
&reference.ds.ds.priorityqueue.capacity;
|
||||
&reference.ds.ds.priorityqueue.clear;
|
||||
&reference.ds.ds.priorityqueue.construct;
|
||||
&reference.ds.ds.priorityqueue.copy;
|
||||
&reference.ds.ds.priorityqueue.count;
|
||||
&reference.ds.ds.priorityqueue.isempty;
|
||||
&reference.ds.ds.priorityqueue.peek;
|
||||
&reference.ds.ds.priorityqueue.pop;
|
||||
&reference.ds.ds.priorityqueue.push;
|
||||
&reference.ds.ds.priorityqueue.toarray;
|
11
reference/ds/ds/entities.queue.xml
Normal file
11
reference/ds/ds/entities.queue.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
&reference.ds.ds.queue.allocate;
|
||||
&reference.ds.ds.queue.capacity;
|
||||
&reference.ds.ds.queue.clear;
|
||||
&reference.ds.ds.queue.construct;
|
||||
&reference.ds.ds.queue.copy;
|
||||
&reference.ds.ds.queue.count;
|
||||
&reference.ds.ds.queue.isempty;
|
||||
&reference.ds.ds.queue.peek;
|
||||
&reference.ds.ds.queue.pop;
|
||||
&reference.ds.ds.queue.push;
|
||||
&reference.ds.ds.queue.toarray;
|
27
reference/ds/ds/entities.sequence.xml
Normal file
27
reference/ds/ds/entities.sequence.xml
Normal file
|
@ -0,0 +1,27 @@
|
|||
&reference.ds.ds.sequence.allocate;
|
||||
&reference.ds.ds.sequence.apply;
|
||||
&reference.ds.ds.sequence.capacity;
|
||||
&reference.ds.ds.sequence.contains;
|
||||
&reference.ds.ds.sequence.filter;
|
||||
&reference.ds.ds.sequence.find;
|
||||
&reference.ds.ds.sequence.first;
|
||||
&reference.ds.ds.sequence.get;
|
||||
&reference.ds.ds.sequence.insert;
|
||||
&reference.ds.ds.sequence.join;
|
||||
&reference.ds.ds.sequence.last;
|
||||
&reference.ds.ds.sequence.map;
|
||||
&reference.ds.ds.sequence.merge;
|
||||
&reference.ds.ds.sequence.pop;
|
||||
&reference.ds.ds.sequence.push;
|
||||
&reference.ds.ds.sequence.reduce;
|
||||
&reference.ds.ds.sequence.remove;
|
||||
&reference.ds.ds.sequence.reverse;
|
||||
&reference.ds.ds.sequence.reversed;
|
||||
&reference.ds.ds.sequence.rotate;
|
||||
&reference.ds.ds.sequence.set;
|
||||
&reference.ds.ds.sequence.shift;
|
||||
&reference.ds.ds.sequence.slice;
|
||||
&reference.ds.ds.sequence.sort;
|
||||
&reference.ds.ds.sequence.sorted;
|
||||
&reference.ds.ds.sequence.sum;
|
||||
&reference.ds.ds.sequence.unshift;
|
28
reference/ds/ds/entities.set.xml
Normal file
28
reference/ds/ds/entities.set.xml
Normal file
|
@ -0,0 +1,28 @@
|
|||
&reference.ds.ds.set.add;
|
||||
&reference.ds.ds.set.allocate;
|
||||
&reference.ds.ds.set.capacity;
|
||||
&reference.ds.ds.set.clear;
|
||||
&reference.ds.ds.set.construct;
|
||||
&reference.ds.ds.set.contains;
|
||||
&reference.ds.ds.set.copy;
|
||||
&reference.ds.ds.set.count;
|
||||
&reference.ds.ds.set.diff;
|
||||
&reference.ds.ds.set.filter;
|
||||
&reference.ds.ds.set.first;
|
||||
&reference.ds.ds.set.get;
|
||||
&reference.ds.ds.set.intersect;
|
||||
&reference.ds.ds.set.isempty;
|
||||
&reference.ds.ds.set.join;
|
||||
&reference.ds.ds.set.last;
|
||||
&reference.ds.ds.set.merge;
|
||||
&reference.ds.ds.set.reduce;
|
||||
&reference.ds.ds.set.remove;
|
||||
&reference.ds.ds.set.reverse;
|
||||
&reference.ds.ds.set.reversed;
|
||||
&reference.ds.ds.set.slice;
|
||||
&reference.ds.ds.set.sort;
|
||||
&reference.ds.ds.set.sorted;
|
||||
&reference.ds.ds.set.sum;
|
||||
&reference.ds.ds.set.toarray;
|
||||
&reference.ds.ds.set.union;
|
||||
&reference.ds.ds.set.xor;
|
11
reference/ds/ds/entities.stack.xml
Normal file
11
reference/ds/ds/entities.stack.xml
Normal file
|
@ -0,0 +1,11 @@
|
|||
&reference.ds.ds.stack.allocate;
|
||||
&reference.ds.ds.stack.capacity;
|
||||
&reference.ds.ds.stack.clear;
|
||||
&reference.ds.ds.stack.construct;
|
||||
&reference.ds.ds.stack.copy;
|
||||
&reference.ds.ds.stack.count;
|
||||
&reference.ds.ds.stack.isempty;
|
||||
&reference.ds.ds.stack.peek;
|
||||
&reference.ds.ds.stack.pop;
|
||||
&reference.ds.ds.stack.push;
|
||||
&reference.ds.ds.stack.toarray;
|
31
reference/ds/ds/entities.vector.xml
Normal file
31
reference/ds/ds/entities.vector.xml
Normal file
|
@ -0,0 +1,31 @@
|
|||
&reference.ds.ds.vector.allocate;
|
||||
&reference.ds.ds.vector.apply;
|
||||
&reference.ds.ds.vector.capacity;
|
||||
&reference.ds.ds.vector.clear;
|
||||
&reference.ds.ds.vector.contains;
|
||||
&reference.ds.ds.vector.copy;
|
||||
&reference.ds.ds.vector.filter;
|
||||
&reference.ds.ds.vector.find;
|
||||
&reference.ds.ds.vector.first;
|
||||
&reference.ds.ds.vector.get;
|
||||
&reference.ds.ds.vector.insert;
|
||||
&reference.ds.ds.vector.isempty;
|
||||
&reference.ds.ds.vector.join;
|
||||
&reference.ds.ds.vector.last;
|
||||
&reference.ds.ds.vector.map;
|
||||
&reference.ds.ds.vector.merge;
|
||||
&reference.ds.ds.vector.pop;
|
||||
&reference.ds.ds.vector.push;
|
||||
&reference.ds.ds.vector.reduce;
|
||||
&reference.ds.ds.vector.remove;
|
||||
&reference.ds.ds.vector.reverse;
|
||||
&reference.ds.ds.vector.reversed;
|
||||
&reference.ds.ds.vector.rotate;
|
||||
&reference.ds.ds.vector.set;
|
||||
&reference.ds.ds.vector.shift;
|
||||
&reference.ds.ds.vector.slice;
|
||||
&reference.ds.ds.vector.sort;
|
||||
&reference.ds.ds.vector.sorted;
|
||||
&reference.ds.ds.vector.sum;
|
||||
&reference.ds.ds.vector.toarray;
|
||||
&reference.ds.ds.vector.unshift;
|
|
@ -8,11 +8,80 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::clear</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Map::clear</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes all values from the map.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Map::clear</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$map = new \Ds\Map([
|
||||
"a" => 1,
|
||||
"b" => 2,
|
||||
"c" => 3,
|
||||
]);
|
||||
print_r($map);
|
||||
|
||||
$map->clear();
|
||||
print_r($map);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Map Object
|
||||
(
|
||||
[0] => Ds\Pair Object
|
||||
(
|
||||
[key] => a
|
||||
[value] => 1
|
||||
)
|
||||
|
||||
[1] => Ds\Pair Object
|
||||
(
|
||||
[key] => b
|
||||
[value] => 2
|
||||
)
|
||||
|
||||
[2] => Ds\Pair Object
|
||||
(
|
||||
[key] => c
|
||||
[value] => 3
|
||||
)
|
||||
|
||||
)
|
||||
Ds\Map Object
|
||||
(
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
101
reference/ds/ds/map/copy.xml
Normal file
101
reference/ds/ds/map/copy.xml
Normal file
|
@ -0,0 +1,101 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-map.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Map::copy</refname>
|
||||
<refpurpose>Returns a shallow copy of the map.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Map</type><methodname>Ds\Map::copy</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a shallow copy of the map.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a shallow copy of the map.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Map::copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$map = new \Ds\Map([
|
||||
"a" => 1,
|
||||
"b" => 2,
|
||||
"c" => 3,
|
||||
]);
|
||||
|
||||
print_r($map->copy());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Map Object
|
||||
(
|
||||
[0] => Ds\Pair Object
|
||||
(
|
||||
[key] => a
|
||||
[value] => 1
|
||||
)
|
||||
|
||||
[1] => Ds\Pair Object
|
||||
(
|
||||
[key] => b
|
||||
[value] => 2
|
||||
)
|
||||
|
||||
[2] => Ds\Pair Object
|
||||
(
|
||||
[key] => c
|
||||
[value] => 3
|
||||
)
|
||||
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
|
@ -4,7 +4,7 @@
|
|||
<refentry xml:id="ds-map.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Map::count</refname>
|
||||
<refpurpose>Returns the number of values in the collection.</refpurpose>
|
||||
<refpurpose>Returns the number of values in the map.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
|
|
|
@ -4,15 +4,58 @@
|
|||
<refentry xml:id="ds-map.isempty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Map::isEmpty</refname>
|
||||
<refpurpose>Returns whether the instance is empty.</refpurpose>
|
||||
<refpurpose>Returns whether the map is empty</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::isEmpty</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Map::isEmpty</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns whether the map is empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns &true; if the map is empty, &false; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Map::isEmpty</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Map(["a" => 1, "b" => 2, "c" => 3]);
|
||||
$b = new \Ds\Map();
|
||||
|
||||
var_dump($a->isEmpty());
|
||||
var_dump($b->isEmpty());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -47,7 +47,7 @@ var_dump($map->pairs());
|
|||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Vector)#8 (3) {
|
||||
object(Ds\Map)#8 (3) {
|
||||
[0]=>
|
||||
object(Ds\Pair)#5 (2) {
|
||||
["key"]=>
|
||||
|
|
|
@ -5,19 +5,82 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Map::toArray</refname>
|
||||
<refpurpose>
|
||||
Converts the instance to an &array;.
|
||||
Converts the map to an &array;.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::toArray</function>
|
||||
</para>
|
||||
<caution>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>array</type><methodname>Ds\Map::toArray</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Converts the map to an &array;.
|
||||
</para>
|
||||
<caution>
|
||||
<para>
|
||||
Maps where non-scalar keys are can't be converted to an &array;.
|
||||
</para>
|
||||
</caution>
|
||||
<caution>
|
||||
<para>
|
||||
An &array; will treat all numeric keys as integers,
|
||||
eg. <code>"1"</code> and <code>1</code> as keys in the map
|
||||
will only result in <code>1</code> being included in the array.
|
||||
</para>
|
||||
</caution>
|
||||
<note>
|
||||
<para>
|
||||
Casting to an &array; is not supported yet.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
An &array; containing all the values in the same order as the map.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Map::toArray</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$map = new \Ds\Map([
|
||||
"a" => 1,
|
||||
"b" => 2,
|
||||
"c" => 3,
|
||||
]);
|
||||
|
||||
var_dump($map->toArray());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(3) {
|
||||
["a"]=>
|
||||
int(1)
|
||||
["b"]=>
|
||||
int(2)
|
||||
["c"]=>
|
||||
int(3)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -46,7 +46,7 @@ var_dump($map->values());
|
|||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Vector)#2 (3) {
|
||||
object(Ds\Map)#2 (3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
|
|
87
reference/ds/ds/pair/clear.xml
Normal file
87
reference/ds/ds/pair/clear.xml
Normal file
|
@ -0,0 +1,87 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-pair.clear" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Pair::clear</refname>
|
||||
<refpurpose>Removes all values.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Pair::clear</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes all values from the pair.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Pair::clear</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$pair = new \Ds\Pair("a", 1);
|
||||
print_r($pair);
|
||||
|
||||
$pair->clear();
|
||||
print_r($pair);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Pair Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Pair Object
|
||||
(
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
|
@ -35,7 +35,7 @@
|
|||
<term><parameter>value</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
They value.
|
||||
The value.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
|
90
reference/ds/ds/pair/copy.xml
Normal file
90
reference/ds/ds/pair/copy.xml
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-pair.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Pair::copy</refname>
|
||||
<refpurpose>Returns a shallow copy of the pair.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Pair</type><methodname>Ds\Pair::copy</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a shallow copy of the pair.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a shallow copy of the pair.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Pair::copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Pair("a", 1);
|
||||
$b = $a->copy();
|
||||
|
||||
$a->key = "x";
|
||||
|
||||
print_r($a);
|
||||
print_r($b);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Pair Object
|
||||
(
|
||||
[key] => x
|
||||
[value] => 1
|
||||
)
|
||||
Ds\Pair Object
|
||||
(
|
||||
[key] => a
|
||||
[value] => 1
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
80
reference/ds/ds/pair/isempty.xml
Normal file
80
reference/ds/ds/pair/isempty.xml
Normal file
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-pair.isempty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Pair::isEmpty</refname>
|
||||
<refpurpose>Returns whether the pair is empty</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Pair::isEmpty</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns whether the pair is empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns &true; if the pair is empty, &false; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Pair::isEmpty</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Pair("a", 1);
|
||||
$b = new \Ds\Pair();
|
||||
|
||||
var_dump($a->isEmpty());
|
||||
var_dump($b->isEmpty());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
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
|
||||
-->
|
|
@ -5,14 +5,64 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Pair::toArray</refname>
|
||||
<refpurpose>
|
||||
Converts the instance to an &array;.
|
||||
Converts the pair to an &array;.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>array</type><methodname>Ds\Pair::toArray</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Converts the pair to an &array;.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
See <function>Ds\Collection::toArray</function>
|
||||
Casting to an &array; is not supported yet.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
An &array; containing all the values in the same order as the pair.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Pair::toArray</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$pair = new \Ds\Pair("a", 1);
|
||||
|
||||
var_dump($pair->toArray());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(2) {
|
||||
["key"]=>
|
||||
string(1) "a"
|
||||
["value"]=>
|
||||
int(1)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -34,6 +34,11 @@
|
|||
current capacity.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
Capacity will always be rounded up to the nearest power of 2.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
@ -45,7 +50,8 @@
|
|||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
<!--
|
||||
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
|
@ -64,13 +70,12 @@ var_dump($queue->capacity());
|
|||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(10)
|
||||
int(100)
|
||||
int(8)
|
||||
int(128)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
-->
|
||||
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
The current capacity.
|
||||
</para>
|
||||
</refsect1>
|
||||
<!--
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
|
@ -39,27 +39,19 @@
|
|||
<?php
|
||||
$queue = new \Ds\PriorityQueue();
|
||||
var_dump($queue->capacity());
|
||||
|
||||
$queue->push(...range(1, 50));
|
||||
var_dump($queue->capacity());
|
||||
|
||||
$queue[] = "a";
|
||||
var_dump($queue->capacity());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(10)
|
||||
int(50)
|
||||
int(75)
|
||||
int(8)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
-->
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,58 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::clear</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\PriorityQueue::clear</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes all values from the queue.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\PriorityQueue::clear</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$queue = new \Ds\PriorityQueue();
|
||||
|
||||
$queue->push("a", 5);
|
||||
$queue->push("b", 15);
|
||||
$queue->push("c", 10);
|
||||
|
||||
$queue->clear();
|
||||
print_r($queue);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\PriorityQueue Object
|
||||
(
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -53,25 +53,13 @@
|
|||
<?php
|
||||
$queue = new \Ds\PriorityQueue();
|
||||
var_dump($queue);
|
||||
|
||||
|
||||
$queue = new \Ds\PriorityQueue([1, 2, 3]);
|
||||
var_dump($queue);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\PriorityQueue)#2 (0) {
|
||||
}
|
||||
object(Ds\PriorityQueue)#2 (3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
object(Ds\PriorityQueue)#1 (0) {
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
|
|
86
reference/ds/ds/priorityqueue/copy.xml
Normal file
86
reference/ds/ds/priorityqueue/copy.xml
Normal file
|
@ -0,0 +1,86 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-priorityqueue.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\PriorityQueue::copy</refname>
|
||||
<refpurpose>Returns a shallow copy of the queue.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\PriorityQueue</type><methodname>Ds\PriorityQueue::copy</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a shallow copy of the queue.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a shallow copy of the queue.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\PriorityQueue::copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$queue = new \Ds\PriorityQueue();
|
||||
|
||||
$queue->push("a", 5);
|
||||
$queue->push("b", 15);
|
||||
$queue->push("c", 10);
|
||||
|
||||
print_r($queue->copy());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\PriorityQueue Object
|
||||
(
|
||||
[0] => b
|
||||
[1] => c
|
||||
[2] => a
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
|
@ -4,7 +4,7 @@
|
|||
<refentry xml:id="ds-priorityqueue.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\PriorityQueue::count</refname>
|
||||
<refpurpose>Returns the number of values in the collection.</refpurpose>
|
||||
<refpurpose>Returns the number of values in the queue.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
|
|
|
@ -4,15 +4,62 @@
|
|||
<refentry xml:id="ds-priorityqueue.isempty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\PriorityQueue::isEmpty</refname>
|
||||
<refpurpose>Returns whether the instance is empty.</refpurpose>
|
||||
<refpurpose>Returns whether the queue is empty</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::isEmpty</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\PriorityQueue::isEmpty</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns whether the queue is empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns &true; if the queue is empty, &false; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\PriorityQueue::isEmpty</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\PriorityQueue();
|
||||
$b = new \Ds\PriorityQueue();
|
||||
|
||||
$a->push("a", 5);
|
||||
$a->push("b", 15);
|
||||
$a->push("c", 10);
|
||||
|
||||
var_dump($a->isEmpty());
|
||||
var_dump($b->isEmpty());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -5,14 +5,75 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\PriorityQueue::toArray</refname>
|
||||
<refpurpose>
|
||||
Converts the instance to an &array;.
|
||||
Converts the queue to an &array;.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>array</type><methodname>Ds\PriorityQueue::toArray</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Converts the queue to an &array;.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
See <function>Ds\Collection::toArray</function>
|
||||
This method is not destructive.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
Casting to an &array; is not supported yet.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
An &array; containing all the values in the same order as the queue.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\PriorityQueue::toArray</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$queue = new \Ds\PriorityQueue();
|
||||
|
||||
$queue->push("a", 5);
|
||||
$queue->push("b", 15);
|
||||
$queue->push("c", 10);
|
||||
|
||||
var_dump($queue->toArray());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(3) {
|
||||
[0]=>
|
||||
string(1) "b"
|
||||
[1]=>
|
||||
string(1) "c"
|
||||
[2]=>
|
||||
string(1) "a"
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -39,6 +39,11 @@
|
|||
current capacity.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
Capacity will always be rounded up to the nearest power of 2.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
|
@ -50,7 +55,7 @@
|
|||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
<!--
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
|
@ -69,13 +74,13 @@ var_dump($queue->capacity());
|
|||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(10)
|
||||
int(100)
|
||||
int(8)
|
||||
int(128)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
-->
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
The current capacity.
|
||||
</para>
|
||||
</refsect1>
|
||||
<!--
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
|
@ -42,24 +42,20 @@ var_dump($queue->capacity());
|
|||
|
||||
$queue->push(...range(1, 50));
|
||||
var_dump($queue->capacity());
|
||||
|
||||
$queue[] = "a";
|
||||
var_dump($queue->capacity());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(10)
|
||||
int(50)
|
||||
int(75)
|
||||
int(8)
|
||||
int(64)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
-->
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,61 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::clear</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Queue::clear</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes all values from the queue.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Queue::clear</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$queue = new \Ds\Queue([1, 2, 3]);
|
||||
print_r($queue);
|
||||
|
||||
$queue->clear();
|
||||
print_r($queue);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Queue Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Queue Object
|
||||
(
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
94
reference/ds/ds/queue/copy.xml
Normal file
94
reference/ds/ds/queue/copy.xml
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-queue.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Queue::copy</refname>
|
||||
<refpurpose>Returns a shallow copy of the queue.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Queue</type><methodname>Ds\Queue::copy</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a shallow copy of the queue.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a shallow copy of the queue.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Queue::copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Queue([1, 2, 3]);
|
||||
$b = $a->copy();
|
||||
|
||||
// Updating the copy doesn't affect the original
|
||||
$b->push(4);
|
||||
|
||||
print_r($a);
|
||||
print_r($b);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Queue Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Queue Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
[3] => 4
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
|
@ -4,7 +4,7 @@
|
|||
<refentry xml:id="ds-queue.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Queue::count</refname>
|
||||
<refpurpose>Returns the number of values in the collection.</refpurpose>
|
||||
<refpurpose>Returns the number of values in the queue.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
|
|
|
@ -4,15 +4,58 @@
|
|||
<refentry xml:id="ds-queue.isempty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Queue::isEmpty</refname>
|
||||
<refpurpose>Returns whether the instance is empty.</refpurpose>
|
||||
<refpurpose>Returns whether the queue is empty</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::isEmpty</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Queue::isEmpty</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns whether the queue is empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns &true; if the queue is empty, &false; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Queue::isEmpty</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Queue([1, 2, 3]);
|
||||
$b = new \Ds\Queue();
|
||||
|
||||
var_dump($a->isEmpty());
|
||||
var_dump($b->isEmpty());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -5,14 +5,71 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Queue::toArray</refname>
|
||||
<refpurpose>
|
||||
Converts the instance to an &array;.
|
||||
Converts the queue to an &array;.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>array</type><methodname>Ds\Queue::toArray</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Converts the queue to an &array;.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
See <function>Ds\Collection::toArray</function>
|
||||
Casting to an &array; is not supported yet.
|
||||
</para>
|
||||
</note>
|
||||
<note>
|
||||
<para>
|
||||
This method is not destructive.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
An &array; containing all the values in the same order as the queue.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Queue::toArray</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$queue = new \Ds\Queue([1, 2, 3]);
|
||||
|
||||
var_dump($queue->toArray());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -8,11 +8,61 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::clear</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Set::clear</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes all values from the set.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Set::clear</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$set = new \Ds\Set([1, 2, 3]);
|
||||
print_r($set);
|
||||
|
||||
$set->clear();
|
||||
print_r($set);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Set Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Set Object
|
||||
(
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
94
reference/ds/ds/set/copy.xml
Normal file
94
reference/ds/ds/set/copy.xml
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-set.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Set::copy</refname>
|
||||
<refpurpose>Returns a shallow copy of the set.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Set</type><methodname>Ds\Set::copy</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a shallow copy of the set.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a shallow copy of the set.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Set::copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Set([1, 2, 3]);
|
||||
$b = $a->copy();
|
||||
|
||||
// Updating the copy doesn't affect the original
|
||||
$b->add(4);
|
||||
|
||||
print_r($a);
|
||||
print_r($b);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Set Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Set Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
[3] => 4
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
|
@ -4,7 +4,7 @@
|
|||
<refentry xml:id="ds-set.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Set::count</refname>
|
||||
<refpurpose>Returns the number of values in the collection.</refpurpose>
|
||||
<refpurpose>Returns the number of values in the set.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
|
|
|
@ -4,15 +4,58 @@
|
|||
<refentry xml:id="ds-set.isempty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Set::isEmpty</refname>
|
||||
<refpurpose>Returns whether the instance is empty.</refpurpose>
|
||||
<refpurpose>Returns whether the set is empty</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::isEmpty</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Set::isEmpty</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns whether the set is empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns &true; if the set is empty, &false; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Set::isEmpty</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Set([1, 2, 3]);
|
||||
$b = new \Ds\Set();
|
||||
|
||||
var_dump($a->isEmpty());
|
||||
var_dump($b->isEmpty());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>abstract</modifier> <modifier>public</modifier> <type>Ds\Set</type><methodname>Ds\Set::merge</methodname>
|
||||
<modifier>public</modifier> <type>Ds\Set</type><methodname>Ds\Set::merge</methodname>
|
||||
<methodparam><type>mixed</type><parameter>values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
|
|
|
@ -5,14 +5,66 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Set::toArray</refname>
|
||||
<refpurpose>
|
||||
Converts the instance to an &array;.
|
||||
Converts the set to an &array;.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>array</type><methodname>Ds\Set::toArray</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Converts the set to an &array;.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
See <function>Ds\Collection::toArray</function>
|
||||
Casting to an &array; is not supported yet.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
An &array; containing all the values in the same order as the set.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Set::toArray</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$set = new \Ds\Set([1, 2, 3]);
|
||||
|
||||
var_dump($set->toArray());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -8,11 +8,61 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::clear</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Stack::clear</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes all values from the stack.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Stack::clear</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$stack = new \Ds\Stack([1, 2, 3]);
|
||||
print_r($stack);
|
||||
|
||||
$stack->clear();
|
||||
print_r($stack);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Stack Object
|
||||
(
|
||||
[0] => 3
|
||||
[1] => 2
|
||||
[2] => 1
|
||||
)
|
||||
Ds\Stack Object
|
||||
(
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -53,27 +53,25 @@
|
|||
<![CDATA[
|
||||
<?php
|
||||
$stack = new \Ds\Stack();
|
||||
var_dump($stack);
|
||||
|
||||
print_r($stack);
|
||||
|
||||
$stack = new \Ds\Stack([1, 2, 3]);
|
||||
var_dump($stack);
|
||||
print_r($stack);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Stack)#2 (0) {
|
||||
}
|
||||
object(Ds\Stack)#2 (3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
Ds\Stack Object
|
||||
(
|
||||
)
|
||||
Ds\Stack Object
|
||||
(
|
||||
[0] => 3
|
||||
[1] => 2
|
||||
[2] => 1
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
|
94
reference/ds/ds/stack/copy.xml
Normal file
94
reference/ds/ds/stack/copy.xml
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-stack.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Stack::copy</refname>
|
||||
<refpurpose>Returns a shallow copy of the stack.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Stack</type><methodname>Ds\Stack::copy</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a shallow copy of the stack.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a shallow copy of the stack.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Stack::copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Stack([1, 2, 3]);
|
||||
$b = $a->copy();
|
||||
|
||||
// Updating the copy doesn't affect the original
|
||||
$b->push(4);
|
||||
|
||||
print_r($a);
|
||||
print_r($b);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Stack Object
|
||||
(
|
||||
[0] => 3
|
||||
[1] => 2
|
||||
[2] => 1
|
||||
)
|
||||
Ds\Stack Object
|
||||
(
|
||||
[0] => 4
|
||||
[1] => 3
|
||||
[2] => 2
|
||||
[3] => 1
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
|
@ -4,7 +4,7 @@
|
|||
<refentry xml:id="ds-stack.count" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Stack::count</refname>
|
||||
<refpurpose>Returns the number of values in the collection.</refpurpose>
|
||||
<refpurpose>Returns the number of values in the stack.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
|
|
|
@ -4,15 +4,58 @@
|
|||
<refentry xml:id="ds-stack.isempty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Stack::isEmpty</refname>
|
||||
<refpurpose>Returns whether the instance is empty.</refpurpose>
|
||||
<refpurpose>Returns whether the stack is empty</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::isEmpty</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Stack::isEmpty</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns whether the stack is empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns &true; if the stack is empty, &false; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Stack::isEmpty</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Stack([1, 2, 3]);
|
||||
$b = new \Ds\Stack();
|
||||
|
||||
var_dump($a->isEmpty());
|
||||
var_dump($b->isEmpty());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -5,14 +5,66 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Stack::toArray</refname>
|
||||
<refpurpose>
|
||||
Converts the instance to an &array;.
|
||||
Converts the stack to an &array;.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>array</type><methodname>Ds\Stack::toArray</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Converts the stack to an &array;.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
See <function>Ds\Collection::toArray</function>
|
||||
Casting to an &array; is not supported yet.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
An &array; containing all the values in the same order as the stack.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Stack::toArray</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$stack = new \Ds\Stack([1, 2, 3]);
|
||||
|
||||
var_dump($stack->toArray());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
array(3) {
|
||||
[0]=>
|
||||
int(3)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(1)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
|
|
|
@ -46,6 +46,32 @@
|
|||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::allocate</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector();
|
||||
var_dump($vector->capacity());
|
||||
|
||||
$vector->allocate(100);
|
||||
var_dump($vector->capacity());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(10)
|
||||
int(100)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,84 @@
|
|||
<refentry xml:id="ds-vector.apply" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Vector::apply</refname>
|
||||
<refpurpose>Applies a callback to each value.</refpurpose>
|
||||
<refpurpose>Updates all values by applying a callback function to each value.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::apply</function>
|
||||
</para>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Vector::apply</methodname>
|
||||
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Updates all values by applying a <parameter>callback</parameter> function to
|
||||
each value in the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>callback</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<methodsynopsis xmlns="http://docbook.org/ns/docbook">
|
||||
<type>mixed</type>
|
||||
<methodname><replaceable>callback</replaceable></methodname>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</para>
|
||||
<para>
|
||||
A <type>callable</type> to apply to each value in the vector.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The callback should return what the value should be replaced by.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::apply</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
$vector->apply(function($value) { return $value * 2; });
|
||||
|
||||
print_r($vector);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Vector Object
|
||||
(
|
||||
[0] => 2
|
||||
[1] => 4
|
||||
[2] => 6
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,58 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::capacity</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>int</type><methodname>Ds\Vector::capacity</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the current capacity.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The current capacity.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::capacity</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector();
|
||||
var_dump($vector->capacity());
|
||||
|
||||
$vector->push(...range(1, 50));
|
||||
var_dump($vector->capacity());
|
||||
|
||||
$vector[] = "a";
|
||||
var_dump($vector->capacity());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(10)
|
||||
int(50)
|
||||
int(75)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,61 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::clear</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Vector::clear</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes all values from the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::clear</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
print_r($vector);
|
||||
|
||||
$vector->clear();
|
||||
print_r($vector);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Vector Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Vector Object
|
||||
(
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,81 @@
|
|||
<refentry xml:id="ds-vector.contains" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Vector::contains</refname>
|
||||
<refpurpose>Determines if the sequence contains all values.</refpurpose>
|
||||
<refpurpose>Determines if the vector contains given values.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::contains</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Vector::contains</methodname>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>...values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Determines if the vector contains all values.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
Values to check.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&false; if any of the provided <parameter>values</parameter> are not in the
|
||||
vector, &true; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::contains</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector(['a', 'b', 'c', 1, 2, 3]);
|
||||
|
||||
var_dump($vector->contains('a')); // true
|
||||
var_dump($vector->contains('a', 'b')); // true
|
||||
var_dump($vector->contains('c', 'd')); // false
|
||||
|
||||
var_dump($vector->contains(...['c', 'b', 'a'])); // true
|
||||
|
||||
// Always strict
|
||||
var_dump($vector->contains(1)); // true
|
||||
var_dump($vector->contains('1')); // false
|
||||
|
||||
var_dump($sequece->contains(...[])); // true
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
bool(true)
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
94
reference/ds/ds/vector/copy.xml
Normal file
94
reference/ds/ds/vector/copy.xml
Normal file
|
@ -0,0 +1,94 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<refentry xml:id="ds-vector.copy" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Vector::copy</refname>
|
||||
<refpurpose>Returns a shallow copy of the vector.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Vector</type><methodname>Ds\Vector::copy</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns a shallow copy of the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns a shallow copy of the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::copy</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Vector([1, 2, 3]);
|
||||
$b = $a->copy();
|
||||
|
||||
// Updating the copy doesn't affect the original
|
||||
$b->push(4);
|
||||
|
||||
print_r($a);
|
||||
print_r($b);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Vector Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
Ds\Vector Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
[3] => 4
|
||||
)
|
||||
]]>
|
||||
</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
|
||||
-->
|
|
@ -5,16 +5,116 @@
|
|||
<refnamediv>
|
||||
<refname>Ds\Vector::filter</refname>
|
||||
<refpurpose>
|
||||
Creates a copy using a <type>callable</type> to determine which values to include.
|
||||
Creates a new vector using a <type>callable</type> to
|
||||
determine which values to include.
|
||||
</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::filter</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Vector</type><methodname>Ds\Vector::filter</methodname>
|
||||
<methodparam choice="opt"><type>callable</type><parameter>callback</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Creates a new vector 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 vector 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\Vector::filter</function> example using callback function</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3, 4, 5]);
|
||||
|
||||
var_dump($vector->filter(function($value) {
|
||||
return $value % 2 == 0;
|
||||
}));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Vector)#3 (2) {
|
||||
[0]=>
|
||||
int(2)
|
||||
[1]=>
|
||||
int(4)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Vector::filter</function> example without a callback function</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([0, 1, 'a', true, false]);
|
||||
|
||||
var_dump($vector->filter());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Vector)#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
|
||||
|
|
|
@ -10,11 +10,72 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::find</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Vector::find</methodname>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the index of the <parameter>value</parameter>, or &false; if not found.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>value</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The value to find.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The index of the value, or &false; if not found.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Values will be compared by value and by type.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::find</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector(["a", 1, true]);
|
||||
|
||||
var_dump($vector->find("a")); // 0
|
||||
var_dump($vector->find("b")); // false
|
||||
var_dump($vector->find("1")); // false
|
||||
var_dump($vector->find(1)); // 1
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(0)
|
||||
bool(false)
|
||||
bool(false)
|
||||
int(1)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,61 @@
|
|||
<refentry xml:id="ds-vector.first" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Vector::first</refname>
|
||||
<refpurpose>Returns the first value.</refpurpose>
|
||||
<refpurpose>Returns the first value in the vector.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::first</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Vector::first</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the first value in the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The first value in the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>UnderflowException</classname> if empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::first</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
var_dump($vector->first());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(1)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,94 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::get</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Vector::get</methodname>
|
||||
<methodparam><type>int</type><parameter>index</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the value at a given index.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>index</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The index to access, starting at 0.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The value at the requested index.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>OutOfRangeException</classname> if the index is not valid.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::get</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector(["a", "b", "c"]);
|
||||
|
||||
var_dump($vector->get(0));
|
||||
var_dump($vector->get(1));
|
||||
var_dump($vector->get(2));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(1) "a"
|
||||
string(1) "b"
|
||||
string(1) "c"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Vector::get</function> example using array syntax</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector(["a", "b", "c"]);
|
||||
|
||||
var_dump($vector[0]);
|
||||
var_dump($vector[1]);
|
||||
var_dump($vector[2]);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(1) "a"
|
||||
string(1) "b"
|
||||
string(1) "c"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,103 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::insert</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Vector::insert</methodname>
|
||||
<methodparam><type>int</type><parameter>index</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>...values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Inserts values into the vector at a given index.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>index</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The index at which to insert. <code>0 <= index <= count</code>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
You can insert at the index equal to the number of values.
|
||||
</para>
|
||||
</note>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The value or values to insert.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>OutOfRangeException</classname> if the index is not valid.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::insert</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector();
|
||||
|
||||
$vector->insert(0, "e"); // [e]
|
||||
$vector->insert(1, "f"); // [e, f]
|
||||
$vector->insert(2, "g"); // [e, f, g]
|
||||
$vector->insert(0, "a", "b"); // [a, b, e, f, g]
|
||||
$vector->insert(2, ...["c", "d"]); // [a, b, c, d, e, f, g]
|
||||
|
||||
var_dump($vector);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Vector)#1 (7) {
|
||||
[0]=>
|
||||
string(1) "a"
|
||||
[1]=>
|
||||
string(1) "b"
|
||||
[2]=>
|
||||
string(1) "c"
|
||||
[3]=>
|
||||
string(1) "d"
|
||||
[4]=>
|
||||
string(1) "e"
|
||||
[5]=>
|
||||
string(1) "f"
|
||||
[6]=>
|
||||
string(1) "g"
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,58 @@
|
|||
<refentry xml:id="ds-vector.isempty" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Vector::isEmpty</refname>
|
||||
<refpurpose>Returns whether the instance is empty.</refpurpose>
|
||||
<refpurpose>Returns whether the vector is empty</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Collection::isEmpty</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>bool</type><methodname>Ds\Vector::isEmpty</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns whether the vector is empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
Returns &true; if the vector is empty, &false; otherwise.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::isEmpty</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$a = new \Ds\Vector([1, 2, 3]);
|
||||
$b = new \Ds\Vector();
|
||||
|
||||
var_dump($a->isEmpty());
|
||||
var_dump($b->isEmpty());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
bool(false)
|
||||
bool(true)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,78 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::join</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>string</type><methodname>Ds\Vector::join</methodname>
|
||||
<methodparam choice="opt"><type>string</type><parameter>glue</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Joins all values together as a string using an optional separator between each value.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>glue</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
An optional string to separate each value.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
All values of the vector joined together as a string.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::join</function> example using a separator string</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector(["a", "b", "c", 1, 2, 3]);
|
||||
|
||||
var_dump($vector->join("|"));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(11) "a|b|c|1|2|3"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Vector::join</function> example without a separator string</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector(["a", "b", "c", 1, 2, 3]);
|
||||
|
||||
var_dump($vector->join());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
string(11) "abc123"
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -7,12 +7,58 @@
|
|||
<refpurpose>Returns the last value.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::last</function>
|
||||
</para>
|
||||
<refsect1 role="description">
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Vector::last</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the last value in the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The last value in the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>UnderflowException</classname> if empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::last</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
var_dump($vector->last());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(3)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,92 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::map</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Vector</type><methodname>Ds\Vector::map</methodname>
|
||||
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the result of applying a <parameter>callback</parameter> function to
|
||||
each value in the vector.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>callback</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<para>
|
||||
<methodsynopsis xmlns="http://docbook.org/ns/docbook">
|
||||
<type>mixed</type>
|
||||
<methodname><replaceable>callback</replaceable></methodname>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
</para>
|
||||
<para>
|
||||
A <type>callable</type> to apply to each value in the vector.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
The callable should return what the new value will be in the new vector.
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The result of applying a <parameter>callback</parameter> to each value in
|
||||
the vector.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
The values of the current instance won't be affected.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::map</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
|
||||
print_r($vector->map(function($value) { return $value * 2; }));
|
||||
print_r($vector);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Vector Object
|
||||
(
|
||||
[0] => 2
|
||||
[1] => 4
|
||||
[2] => 6
|
||||
)
|
||||
Ds\Vector Object
|
||||
(
|
||||
[0] => 1
|
||||
[1] => 2
|
||||
[2] => 3
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,93 @@
|
|||
<refentry xml:id="ds-vector.merge" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Vector::merge</refname>
|
||||
<refpurpose>Returns the result of adding all given values.</refpurpose>
|
||||
<refpurpose>Returns the result of adding all given values to the vector.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::merge</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>Ds\Vector</type><methodname>Ds\Vector::merge</methodname>
|
||||
<methodparam><type>mixed</type><parameter>values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Returns the result of adding all given values to the vector.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
A <classname>traversable</classname> object or an &array;.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The result of adding all given values to the vector,
|
||||
effectively the same as adding the values to a copy, then returning that copy.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
The current instance won't be affected.
|
||||
</para>
|
||||
</note>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::merge</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
|
||||
var_dump($vector->merge([4, 5, 6]));
|
||||
var_dump($vector);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
object(Ds\Vector)#2 (6) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
[3]=>
|
||||
int(4)
|
||||
[4]=>
|
||||
int(5)
|
||||
[5]=>
|
||||
int(6)
|
||||
}
|
||||
object(Ds\Vector)#1 (3) {
|
||||
[0]=>
|
||||
int(1)
|
||||
[1]=>
|
||||
int(2)
|
||||
[2]=>
|
||||
int(3)
|
||||
}
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -8,11 +8,63 @@
|
|||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::pop</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Vector::pop</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Removes and returns the last value.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
&no.function.parameters;
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The removed last value.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="errors">
|
||||
&reftitle.errors;
|
||||
<para>
|
||||
<classname>UnderflowException</classname> if empty.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::pop</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
|
||||
var_dump($vector->pop());
|
||||
var_dump($vector->pop());
|
||||
var_dump($vector->pop());
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(3)
|
||||
int(2)
|
||||
int(1)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,78 @@
|
|||
<refentry xml:id="ds-vector.push" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Vector::push</refname>
|
||||
<refpurpose>Adds values to the end of the sequence.</refpurpose>
|
||||
<refpurpose>Adds values to the end of the vector.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::push</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>void</type><methodname>Ds\Vector::push</methodname>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>...values</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Adds values to the end of the vector.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>values</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The values to add.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
&return.void;
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::push</function> example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector();
|
||||
|
||||
$vector->push("a");
|
||||
$vector->push("b");
|
||||
$vector->push("c", "d");
|
||||
$vector->push(...["e", "f"]);
|
||||
|
||||
print_r($vector);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Ds\Vector Object
|
||||
(
|
||||
[0] => a
|
||||
[1] => b
|
||||
[2] => c
|
||||
[3] => d
|
||||
[4] => e
|
||||
[5] => f
|
||||
)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
|
@ -4,15 +4,137 @@
|
|||
<refentry xml:id="ds-vector.reduce" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
||||
<refnamediv>
|
||||
<refname>Ds\Vector::reduce</refname>
|
||||
<refpurpose>Reduces the sequence to a single value using a callback function.</refpurpose>
|
||||
<refpurpose>Reduces the vector to a single value using a callback function.</refpurpose>
|
||||
</refnamediv>
|
||||
|
||||
<refsect1 role="description">
|
||||
<para>
|
||||
See <function>Ds\Sequence::reduce</function>
|
||||
</para>
|
||||
&reftitle.description;
|
||||
<methodsynopsis>
|
||||
<modifier>public</modifier> <type>mixed</type><methodname>Ds\Vector::reduce</methodname>
|
||||
<methodparam><type>callable</type><parameter>callback</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>initial</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Reduces the vector to a single value using a callback function.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="parameters">
|
||||
&reftitle.parameters;
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>callback</parameter></term>
|
||||
|
||||
<listitem>
|
||||
<methodsynopsis>
|
||||
<type>mixed</type><methodname><replaceable>callback</replaceable></methodname>
|
||||
<methodparam><type>mixed</type><parameter>carry</parameter></methodparam>
|
||||
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<variablelist>
|
||||
<varlistentry>
|
||||
<term><parameter>carry</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The return value of the previous callback, or <parameter>initial</parameter> if
|
||||
it's the first iteration.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>value</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The value of the current iteration.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</listitem>
|
||||
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><parameter>initial</parameter></term>
|
||||
<listitem>
|
||||
<para>
|
||||
The initial value of the carry value. Can be &null;.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
</variablelist>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="returnvalues">
|
||||
&reftitle.returnvalues;
|
||||
<para>
|
||||
The return value of the final callback.
|
||||
</para>
|
||||
</refsect1>
|
||||
|
||||
<refsect1 role="examples">
|
||||
&reftitle.examples;
|
||||
<example>
|
||||
<title><function>Ds\Vector::reduce</function> with initial value example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
|
||||
$callback = function($carry, $value) {
|
||||
return $carry * $value;
|
||||
};
|
||||
|
||||
var_dump($vector->reduce($callback, 5));
|
||||
|
||||
// Iterations:
|
||||
//
|
||||
// $carry = $initial = 5
|
||||
//
|
||||
// $carry = $carry * 1 = 5
|
||||
// $carry = $carry * 2 = 10
|
||||
// $carry = $carry * 3 = 30
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(30)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title><function>Ds\Vector::reduce</function> without an initial value example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$vector = new \Ds\Vector([1, 2, 3]);
|
||||
|
||||
var_dump($vector->reduce(function($carry, $value) {
|
||||
return $carry + $value + 5;
|
||||
}));
|
||||
|
||||
// Iterations:
|
||||
//
|
||||
// $carry = $initial = null
|
||||
//
|
||||
// $carry = $carry + 1 + 5 = 6
|
||||
// $carry = $carry + 2 + 5 = 13
|
||||
// $carry = $carry + 3 + 5 = 21
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
&example.outputs.similar;
|
||||
<screen>
|
||||
<![CDATA[
|
||||
int(21)
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</refsect1>
|
||||
|
||||
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue