PHP Conference Japan 2024

QuickHashIntSet::loadFromFile

(PECL quickhash >= Unknown)

QuickHashIntSet::loadFromFile此工廠方法從檔案建立集合

描述

public static QuickHashIntSet::loadFromFile(string $filename, int $size = ?, int $options = ?): QuickHashIntSet

此工廠方法從磁碟上的定義檔建立一個新的集合。檔案格式由 32 位元帶符號整數組成,這些整數以程式碼執行的系統使用的位元組順序封裝在一起。

參數

filename

要從中讀取集合的檔案名稱。

size

要配置的桶列表數量。您傳入的數字會自動四捨五入到下一個 2 的冪次方。它也會自動限制在 44194304 之間。

options

該類別的建構函式採用的相同選項;不同之處在於大小選項會被忽略。它會自動計算為與集合中的條目數相同,四捨五入到最接近的 2 的冪次方,最大限制為 4194304

傳回值

傳回一個新的 QuickHashIntSet

範例

範例 1 QuickHashIntSet::loadFromFile() 範例

<?php
$file
= dirname( __FILE__ ) . "/simple.set";
$set = QuickHashIntSet::loadFromFile(
$file,
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

新增筆記

使用者貢獻的筆記

此頁面沒有使用者貢獻的筆記。
To Top