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

<refentry xml:id="pht-vector.insertAt" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>pht\Vector::insertAt</refname>
  <refpurpose>Inserts a value into the vector</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>void</type><methodname>pht\Vector::insertAt</methodname>
   <methodparam><type>mixed</type><parameter>value</parameter></methodparam>
   <methodparam><type>int</type><parameter>offset</parameter></methodparam>
  </methodsynopsis>
  <para>
   This method inserts a value at the specified offset into the 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 inserted into the vector. This value will be serialised
      (since it may be passed around between threads).
     </para>
    </listitem>
   </varlistentry>
   <varlistentry>
    <term><parameter>offset</parameter></term>
    <listitem>
     <para>
      The offset at which the value will be inserted at. This offset must be
      within the 0..N range (inclusive), where N is the size of the vector.
      Inserting at position N is the equivalent of using
      <methodname>pht\Vector::push</methodname>, and inserting at position 0 is the
      equivalent of using <methodname>pht\Vector::unshift</methodname>. Attempting
      to insert at offsets outside of this range will result in an
      <classname>Error</classname> exception.
     </para>
    </listitem>
   </varlistentry>
  </variablelist>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   No return value.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title>Inserting a value into a vector</title>
    <programlisting role="php">
<![CDATA[
<?php

use pht\Vector;

$vector = new Vector();

$vector->insertAt(3, 0); // insert 3 at start
$vector->insertAt(1, 0); // insert 1 at start (before 3)
$vector->insertAt(2, 1); // insert 2 in middle (after 1 and before 3)

var_dump($vector);
]]>
    </programlisting>
    &example.outputs;
    <screen>
<![CDATA[
object(pht\Vector)#1 (3) {
  [0]=>
  int(1)
  [1]=>
  int(2)
  [2]=>
  int(3)
}
]]>
    </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
-->