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

<refentry xml:id="quickhashintstringhash.set" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
 <refnamediv>
  <refname>QuickHashIntStringHash::set</refname>
  <refpurpose>This method updates an entry in the hash with a new value, or
  adds a new one if the entry doesn't exist</refpurpose>
 </refnamediv>

 <refsect1 role="description">
  &reftitle.description;
  <methodsynopsis>
   <modifier>public</modifier> <type>int</type><methodname>QuickHashIntStringHash::set</methodname>
   <methodparam><type>int</type><parameter>key</parameter></methodparam>
   <methodparam><type>string</type><parameter>value</parameter></methodparam>
  </methodsynopsis>
  <para>
   This method tries to update an entry with a new value. In case the entry
   did not yet exist, it will instead add a new entry. It returns whether the
   entry was added or update. If there are duplicate keys, only the first
   found element will get an updated value. Use
   QuickHashIntStringHash::CHECK_FOR_DUPES during hash creation to prevent duplicate
   keys from being part of the hash.
  </para>
 </refsect1>

 <refsect1 role="parameters">
  &reftitle.parameters;
  <para>
   <variablelist>
    <varlistentry>
     <term><parameter>key</parameter></term>
     <listitem>
      <para>
       The key of the entry to add or update.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry>
     <term><parameter>value</parameter></term>
     <listitem>
      <para>
       The value of the entry to add. If a non-string is passed, it will be
       converted to a string automatically if possible.
      </para>
     </listitem>
    </varlistentry>
   </variablelist>
  </para>
 </refsect1>

 <refsect1 role="returnvalues">
  &reftitle.returnvalues;
  <para>
   2 if the entry was found and updated, 1 if the entry was newly added or 0
   if there was an error.
  </para>
 </refsect1>

 <refsect1 role="examples">
  &reftitle.examples;
  <para>
   <example>
    <title><function>QuickHashIntStringHash::set</function> example</title>
    <programlisting role="php">
<![CDATA[
<?php
$hash = new QuickHashIntStringHash( 1024 );

echo "Set->Add\n";
var_dump( $hash->get( 46692 ) );
var_dump( $hash->set( 46692, "sixteen thousand ninety one" ) );
var_dump( $hash->get( 46692 ) );

echo "Set->Update\n";
var_dump( $hash->set( 46692, "twenty nine thousand nine hundred six" ) );
var_dump( $hash->get( 46692 ) );
?>
]]>
    </programlisting>
    &example.outputs.similar;
    <screen>
<![CDATA[
Set->Add
bool(false)
int(2)
string(27) "sixteen thousand ninety one"
Set->Update
int(1)
string(37) "twenty nine thousand nine hundred six"
]]>
    </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
-->
