Quickhash QuickHashIntHash::loadFromFile

(PECL quickhash >= Unknown)

QuickHashIntHash::loadFromFile — 이 팩토리 메소드는 파일에서 해시를 생성합니다.


설명

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

이 팩토리 메소드는 디스크의 정의 파일에서 새 해시를 생성합니다. 파일 형식은 서명 'QH\0x11\0', 시스템 엔디안에서 32비트 부호 있는 정수로 된 요소 수, 그 뒤에 코드가 실행되는 시스템에서 사용하는 엔디안에서 함께 묶인 32비트 부호 있는 정수로 구성됩니다. 각 해시 요소에 대해 2개의 32비트 부호 있는 정수가 저장됩니다. 각 요소의 첫 번째는 키이고 두 번째는 키에 속한 값입니다. 예를 들면 다음과 같습니다.

예제 #1 QuickHash IntHash 파일 형식

00000000  51 48 11 00 02 00 00 00  01 00 00 00 01 00 00 00  |QH..............|
00000010  03 00 00 00 09 00 00 00                           |........|
00000018
                

예제 #2 QuickHash IntHash 파일 형식

header signature ('QH'; key type: 1; value type: 1; filler: \0x00)
00000000  51 48 11 00

number of elements:
00000004  02 00 00 00

data string:
00000000  01 00 00 00 01 00 00 00  03 00 00 00 09 00 00 00

key/value 1 (key = 1, value = 1)
01 00 00 00  01 00 00 00

key/value 2 (key = 3, value = 9)
03 00 00 00  09 00 00 00
                

매개변수

filename
해시를 읽을 파일의 파일 이름입니다.
options
클래스의 생성자가 취하는 것과 동일한 옵션; 크기 옵션이 무시된다는 점을 제외하고. 해시의 항목 수와 동일하도록 자동 계산되며 최대 제한은 4194304이며 가장 가까운 2의 거듭제곱으로 반올림됩니다.

반환 값

새로운 QuickHashIntHash를 반환합니다.


Examples

예제 #3 QuickHashIntHash::loadFromFile() 예제

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