Quickhash QuickHashIntStringHash::loadFromFile

(PECL quickhash >= Unknown)

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


설명

public static QuickHashIntStringHash::loadFromFile(string $filename, int $size = 0, int $options = 0): QuickHashIntStringHash

이 팩토리 메소드는 디스크의 정의 파일에서 새 해시를 생성합니다. 파일 형식은 서명 'QH\0x12\0', 시스템 Endianness에서 32비트 부호 있는 정수로서의 요소 수, 문자로 따를 요소 데이터 수를 포함하는 부호 없는 32비트 정수로 구성됩니다. 이 요소 데이터에는 모든 문자열이 포함됩니다. 헤더와 문자열 다음에 요소가 두 개의 부호 없는 32비트 정수 쌍으로 뒤따릅니다. 여기서 첫 번째는 키이고 두 번째는 요소 데이터 문자열의 인덱스입니다. 예를 들면 다음과 같습니다.

예제 #1 QuickHash IntString 파일 형식

00000000  51 48 12 00 02 00 00 00  09 00 00 00 4f 4e 45 00  |QH..........ONE.|
00000010  4e 49 4e 45 00 01 00 00  00 00 00 00 00 03 00 00  |NINE............|
00000020  00 04 00 00 00                                    |.....|
00000025
                

예제 #2 QuickHash IntString 파일 형식

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

number of elements:
00000004  02 00 00 00

length of string values (9 characters):
00000008  09 00 00 00

string values:
0000000C  4f 4e 45 00 4e 49 4e 45  00

data string:
00000015  01 00 00 00 00 00 00 00  03 00 00 00 04 00 00 00

key/value 1 (key = 1, string index = 0 ("ONE")):
01 00 00 00  00 00 00 00

key/value 2 (key = 3, string index = 4 ("NINE")):
03 00 00 00  04 00 00 00
                

매개변수

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

반환 값

새로운 QuickHashIntStringHash를 반환합니다.


Examples

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

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