Quickhash QuickHashIntHash::loadFromString
(PECL quickhash >= Unknown)
QuickHashIntHash::loadFromString — 이 팩토리 메소드는 문자열에서 해시를 생성합니다.
설명
public static QuickHashIntHash::loadFromString(string $contents
, int $options
= ?): QuickHashIntHash
이 팩토리 메서드는 문자열의 정의에서 새 해시를 만듭니다. 파일 형식은 코드가 실행되는 시스템이 사용하는 Endianness로 함께 묶인 32비트 부호 있는 정수로 구성됩니다. 각 요소에 대해 두 개의 32비트 부호 있는 정수가 저장됩니다. 각 요소의 첫 번째는 키이고 두 번째는 키에 속한 값입니다.
매개변수
contents
- 직렬화된 해시 형식을 포함하는 문자열입니다.
options
- 클래스의 생성자가 취하는 것과 동일한 옵션; 크기 옵션이 무시된다는 점을 제외하고. 해시의 항목 수와 동일하도록 자동 계산되며 최대 제한은
4194304
이며 가장 가까운 2의 거듭제곱으로 반올림됩니다.
반환 값
새로운 QuickHashIntHash를 반환합니다.
Examples
예제 #1 QuickHashIntHash::loadFromString() 예제
<?php
$contents = file_get_contents( dirname( __FILE__ ) . "/simple.hash" );
$hash = QuickHashIntHash::loadFromString(
$contents,
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