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