Php/docs/quickhashintstringhash.loadfromstring

提供:Dev Guides
< Php
移動先:案内検索

QuickHashIntStringHash::loadFromString

(PECL quickhash >= Unknown)

QuickHashIntStringHash::loadFromString文字列からハッシュを作るファクトリーメソッド


説明

public static QuickHashIntStringHash::loadFromString ( string $contents [, int $size = 0 [, int $options = 0 ]] ) : QuickHashIntStringHash

文字列の定義から新しいハッシュを作るファクトリーメソッドです。 フォーマットは "loadFromFile" で使うものと同じです。


パラメータ

contents
ハッシュをシリアライズした文字列。
size
バケツリストの数。 ここに渡した値は、直近の 2 の階乗まで切り上げられます。また、自動的に 4 から 4194304 までの範囲になります。
options
クラスのコンストラクタが受け取るのと同じオプション。 size オプションは無視されます。 サイズはハッシュのエントリをもとにして自動的に算出され、 2 の階乗の中で直近の値に切り上げられます。 最大値は 4194304 です。


返り値

新しい QuickHashIntStringHash を返します。


例1 QuickHashIntStringHash::loadFromString() の例

<?php$contents = file_get_contents( dirname( __FILE__ ) . "/simple.hash" );$hash = QuickHashIntStringHash::loadFromString(    $contents,    QuickHashIntStringHash::DO_NOT_USE_ZEND_ALLOC);foreach( range( 0, 0x0f ) as $key ){    printf( "Key %3d (%2x) is %s\n",        $key, $key,         $hash->exists( $key ) ? 'set' : 'unset'    );}?>

上の例の出力は、 たとえば以下のようになります。


Key   0 ( 0) is unset
Key   1 ( 1) is set
Key   2 ( 2) is set
Key   3 ( 3) is set
Key   4 ( 4) is unset
Key   5 ( 5) is set
Key   6 ( 6) is unset
Key   7 ( 7) is set
Key   8 ( 8) is unset
Key   9 ( 9) is unset
Key  10 ( a) is unset
Key  11 ( b) is set
Key  12 ( c) is unset
Key  13 ( d) is set
Key  14 ( e) is unset
Key  15 ( f) is unset