1
0
mirror of https://github.com/php/doc-ru.git synced 2026-03-26 16:52:12 +01:00
Files
archived-doc-ru/reference/quickhash/quickhashstringinthash/loadfromstring.xml
2024-06-19 04:41:48 +03:00

140 lines
4.5 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: bfa171ecb7d958d09e9fd576090c95a62caff784 Maintainer: sergey Status: ready -->
<!-- Reviewed: no -->
<refentry xml:id="quickhashstringinthash.loadfromstring" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>QuickHashStringIntHash::loadFromString</refname>
<refpurpose>Создаёт хеш из строки</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <modifier>static</modifier> <type>QuickHashStringIntHash</type><methodname>QuickHashStringIntHash::loadFromString</methodname>
<methodparam><type>string</type><parameter>contents</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>size</parameter><initializer>0</initializer></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
</methodsynopsis>
<para>
Этот фабричный метод создаёт новый хеш из определения в строке.
Формат такой же, как и в методе <methodname>QuickHashStringIntHash::loadFromFile</methodname>.
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>contents</parameter></term>
<listitem>
<para>
Строка, которая содержит сериализованный формат хеша.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>size</parameter></term>
<listitem>
<para>
Количество списков бакетов для настройки.
Метод автоматически округлит заданное число в бо́льшую сторону до следующей степени числа 2.
Оно также автоматически ограничивается значениями от <literal>4</literal> до <literal>4 194 304</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
Те же параметры, которые принимает конструктор класса;
за исключением того, что параметр <literal>size</literal> игнорируется.
Размер автоматически вычисляется как количество записей в хеше,
округляется в бо́льшую сторону до ближайшей степени числа 2
с максимальным пределом <literal>4 194 304</literal>.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Метод возвращает новый объект <classname>QuickHashStringIntHash</classname>.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Пример использования метода <function>QuickHashStringIntHash::loadFromString</function></title>
<programlisting role="php">
<![CDATA[
<?php
$contents = file_get_contents(dirname(__FILE__) . "/simple.hash.string");
$hash = QuickHashStringIntHash::loadFromString(
$contents,
QuickHashStringIntHash::DO_NOT_USE_ZEND_ALLOC
);
foreach (range(0, 0x0f) as $key) {
$i = 48712 + $key * 1631;
$k = base_convert($i, 10, 36);
echo $k, ' => ', $hash->get($k), "\n";
}
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
11l4 => 48712
12uf => 50343
143q => 51974
15d1 => 53605
16mc => 55236
17vn => 56867
194y => 58498
1ae9 => 60129
1bnk => 61760
1cwv => 63391
1e66 => 65022
1ffh => 66653
1gos => 68284
1hy3 => 69915
1j7e => 71546
1kgp => 73177
]]>
</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
-->