Quickhash QuickHashIntHash::exists
(PECL quickhash >= Unknown)
QuickHashIntHash::exists — 이 메서드는 키가 해시의 일부인지 확인합니다.
설명
public QuickHashIntHash::exists(int $key
): bool
이 메서드는 제공된 키가 있는 항목이 해시에 존재하는지 확인합니다.
매개변수
key
- 해시에 존재하는지 여부를 확인하기 위한 항목의 키입니다.
반환 값
항목을 찾으면 true
를 반환하고 항목을 찾지 못하면 false
를 반환합니다.
Examples
예제 #1 QuickHashIntHash::exists() 예제
<?php
//generate 200000 elements
$array = range( 0, 199999 );
$existingEntries = array_rand( array_flip( $array ), 180000 );
$testForEntries = array_rand( array_flip( $array ), 1000 );
$foundCount = 0;
echo "Creating hash: ", microtime( true ), "\n";
$hash = new QuickHashIntHash( 100000 );
echo "Adding elements: ", microtime( true ), "\n";
foreach( $existingEntries as $key )
{
$hash->add( $key, 56 );
}
echo "Doing 1000 tests: ", microtime( true ), "\n";
foreach( $testForEntries as $key )
{
$foundCount += $hash->exists( $key );
}
echo "Done, $foundCount found: ", microtime( true ), "\n";
?>
위의 예는 다음과 유사한 결과를 출력합니다.
Creating hash: 1263588703.0748 Adding elements: 1263588703.0757 Doing 1000 tests: 1263588703.7851 Done, 898 found: 1263588703.7897