Php/docs/quickhashintset.loadfromstring

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

QuickHashIntSet::loadFromString

(PECL quickhash >= Unknown)

QuickHashIntSet::loadFromString文字列からセットを作るファクトリーメソッド


説明

public static QuickHashIntSet::loadFromString ( string $contents [, int $size [, int $options ]] ) : QuickHashIntSet

文字列の定義から新しいセットを作るファクトリーメソッドです。 ファイルフォーマットは、システムと同じエンディアンでパックされた 32 ビット符号付き整数値です。


パラメータ

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


返り値

新しい QuickHashIntSet を返します。


例1 QuickHashIntSet::loadFromString() の例

<?php$contents = file_get_contents( dirname( __FILE__ ) . "/simple.set" );$set = QuickHashIntSet::loadFromString(    $contents,    QuickHashIntSet::DO_NOT_USE_ZEND_ALLOC);foreach( range( 0, 0x0f ) as $key ){    printf( "Key %3d (%2x) is %s\n",        $key, $key,         $set->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