mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-27 06:18:56 +00:00

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@321911 c90b9560-bf6c-de11-be94-00142212c4b1
138 lines
3.2 KiB
XML
138 lines
3.2 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
|
|
<refentry xml:id="quickhashinthash.add" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
<refnamediv>
|
|
<refname>QuickHashIntHash::add</refname>
|
|
<refpurpose>This method adds a new entry to the hash</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<modifier>public</modifier> <type>bool</type><methodname>QuickHashIntHash::add</methodname>
|
|
<methodparam><type>int</type><parameter>key</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>value</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
This method adds a new entry to the hash, and returns whether the entry was
|
|
added. Entries are by default always added unless
|
|
QuickHashIntHash::CHECK_FOR_DUPES has been passed when the hash was created.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>key</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The key of the entry to add.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>value</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
The optional value of the entry to add. If no value is specified,
|
|
<literal>1</literal> will be used.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
&true; when the entry was added, and &false; if the entry was not added.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title><function>QuickHashIntHash::add</function> example</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
echo "without dupe checking\n";
|
|
$hash = new QuickHashIntHash( 1024 );
|
|
var_dump( $hash->exists( 4 ) );
|
|
var_dump( $hash->get( 4 ) );
|
|
var_dump( $hash->add( 4, 22 ) );
|
|
var_dump( $hash->exists( 4 ) );
|
|
var_dump( $hash->get( 4 ) );
|
|
var_dump( $hash->add( 4, 12 ) );
|
|
|
|
echo "\nwith dupe checking\n";
|
|
$hash = new QuickHashIntHash( 1024, QuickHashIntHash::CHECK_FOR_DUPES );
|
|
var_dump( $hash->exists( 4 ) );
|
|
var_dump( $hash->get( 4 ) );
|
|
var_dump( $hash->add( 4, 78 ) );
|
|
var_dump( $hash->exists( 4 ) );
|
|
var_dump( $hash->get( 4 ) );
|
|
var_dump( $hash->add( 4, 9 ) );
|
|
|
|
echo "\ndefault value\n";
|
|
var_dump( $hash->add( 5 ) );
|
|
var_dump( $hash->get( 5 ) );
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
without dupe checking
|
|
bool(false)
|
|
bool(false)
|
|
bool(true)
|
|
bool(true)
|
|
int(22)
|
|
bool(true)
|
|
|
|
with dupe checking
|
|
bool(false)
|
|
bool(false)
|
|
bool(true)
|
|
bool(true)
|
|
int(78)
|
|
bool(false)
|
|
|
|
default value
|
|
bool(true)
|
|
int(1)
|
|
]]>
|
|
</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
|
|
-->
|