mirror of
https://github.com/php/doc-pt_br.git
synced 2026-03-23 22:52:12 +01:00
150 lines
2.9 KiB
XML
150 lines
2.9 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: 12ff796708d2460fed5a241950e667ea938d07e7 Maintainer: leonardolara Status: ready -->
|
|
|
|
<chapter xml:id="quickhash.examples" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
|
|
&reftitle.examples;
|
|
<example>
|
|
<title>Exemplo de Quickhash</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$set = new QuickHashIntSet( 1024, QuickHashIntSet::CHECK_FOR_DUPES );
|
|
$set->add( 1 );
|
|
$set->add( 3 );
|
|
|
|
var_dump( $set->exists( 3 ) );
|
|
var_dump( $set->exists( 4 ) );
|
|
|
|
$set->saveToFile( "/tmp/test-set.set" );
|
|
|
|
$newSet = QuickHashIntSet::loadFromFile(
|
|
"/tmp/test-set.set"
|
|
);
|
|
|
|
var_dump( $newSet->exists( 3 ) );
|
|
var_dump( $newSet->exists( 4 ) );
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
bool(true)
|
|
bool(false)
|
|
bool(true)
|
|
bool(false)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<example>
|
|
<title>Exemplo de ArrayAccess do Quickhash</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$hash = new QuickHashIntHash( 64 );
|
|
|
|
// Adicionando e atualizando entradas de hash.
|
|
$hash[3] = 145926;
|
|
$hash[3] = 1415926;
|
|
$hash[2] = 72;
|
|
|
|
// Verificando se as chaves existem
|
|
var_dump( isset( $hash[3] ) );
|
|
|
|
// Removendo entradas de hash
|
|
unset( $hash[2] );
|
|
|
|
// Recuperando o valor armazenado para um hash
|
|
echo $hash[3], "\n";
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
bool(true)
|
|
1415926
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<example>
|
|
<title>Exemplo de iterador Quickhash</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$hash = new QuickHashIntHash( 64 );
|
|
|
|
// Adicionando entradas de hash
|
|
$hash[1] = 145926;
|
|
$hash[2] = 1415926;
|
|
$hash[3] = 72;
|
|
$hash[4] = 712314;
|
|
$hash[5] = -4234;
|
|
|
|
foreach( $hash as $key => $value )
|
|
{
|
|
echo $key, ' => ', $value, "\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
5 => -4234
|
|
4 => 712314
|
|
1 => 145926
|
|
2 => 1415926
|
|
3 => 72
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
<example>
|
|
<title>Exemplo de valores de string Quickhash</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$hash = new QuickHashIntStringHash( 64 );
|
|
|
|
// Adicionando entradas de hash
|
|
$hash[1] = "um milhão quatrocentos e quinze mil novecentos e vinte e seis";
|
|
$hash->add( 2, "mais um" );
|
|
|
|
foreach( $hash as $key => $value )
|
|
{
|
|
echo $key, ' => ', $value, "\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs.similar;
|
|
<screen>
|
|
<![CDATA[
|
|
1 => um milhão quatrocentos e quinze mil novecentos e vinte e seis
|
|
2 => mais um
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</chapter>
|
|
|
|
<!-- 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
|
|
-->
|