php-doc-en/reference/pht/vector/unshift.xml
2018-02-11 18:55:13 +00:00

101 lines
2.2 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="pht.vector.unshift" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Vector::unshift</refname>
<refpurpose>Unshifts a value to the vector front</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>void</type><methodname>Vector::unshift</methodname>
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
</methodsynopsis>
<para>
This method unshifts a value to the front of a vector (in linear time). The
vector will automatically be resized if it is not large enough.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<variablelist>
<varlistentry>
<term><parameter>value</parameter></term>
<listitem>
<para>
The value to be pushed onto the beginning of the vector. This value will
be serialised (since it may be passed around between threads).
</para>
</listitem>
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
No return value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Unshifting a value to the front of a vector</title>
<programlisting role="php">
<![CDATA[
<?php
use pht\Vector;
$vector = new Vector();
for ($i = 0; $i < 3; ++$i) {
$vector->unshift($i); // causes a quadratic runtime, beware
}
var_dump($vector);
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
object(pht\Vector)#1 (3) {
[0]=>
int(2)
[1]=>
int(1)
[2]=>
int(0)
}
]]>
</screen>
</example>
</para>
</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
-->