(PECL quickhash >= 未知)
QuickHashIntSet::loadFromString — 此工廠方法從字串建立集合
$contents
, int $size
= ?, int $options
= ?): QuickHashIntSet此工廠方法從字串中的定義建立新的集合。檔案格式由 32 位元帶符號整數組成,這些整數以程式碼執行所在系統使用的位元組順序打包在一起。
contents
包含集合序列化格式的字串。
size
要設定的桶列表數量。您傳入的數字將自動向上捨入到下一個 2 的次方數。它還會自動限制在 4
到 4194304
之間。
選項
與類別建構函式相同的選項;除了大小選項會被忽略。它會自動計算為與集合中條目的數量相同,向上捨入到最接近的 2 的次方數,並自動限制在 64
到 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( "鍵 %3d (%2x) %s\n",
$key, $key,
$set->exists( $key ) ? '已設定' : '未設定'
);
}
?>
上述範例將輸出類似以下的內容
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