QuickHashIntSet::delete
(PECL quickhash >= Unknown)
QuickHashIntSet::delete — This method deletes an entry from the set
Описание
public bool QuickHashIntSet::delete
( int
$key
)This method deletes an entry from the set, and returns whether the entry was deleted or not. Associated memory structures will not be freed immediately, but rather when the set itself is freed.
Список параметров
-
key
-
The key of the entry to delete.
Возвращаемые значения
TRUE
when the entry was deleted, and FALSE
if the entry was not deleted.
Примеры
Пример #1 QuickHashIntSet::delete() example
<?php
$set = new QuickHashIntSet( 1024 );
var_dump( $set->exists( 4 ) );
var_dump( $set->add( 4 ) );
var_dump( $set->delete( 4 ) );
var_dump( $set->exists( 4 ) );
var_dump( $set->delete( 4 ) );
?>
Результатом выполнения данного примера будет что-то подобное:
bool(false) bool(true) bool(true) bool(false) bool(false)
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения, относящиеся к переменным и типам
- Quickhash
- Функция QuickHashIntSet::add() - This method adds a new entry to the set
- Функция QuickHashIntSet::__construct() - Creates a new QuickHashIntSet object
- Функция QuickHashIntSet::delete() - This method deletes an entry from the set
- Функция QuickHashIntSet::exists() - This method checks whether a key is part of the set
- Функция QuickHashIntSet::getSize() - Returns the number of elements in the set
- Функция QuickHashIntSet::loadFromFile() - This factory method creates a set from a file
- Функция QuickHashIntSet::loadFromString() - This factory method creates a set from a string
- Функция QuickHashIntSet::saveToFile() - This method stores an in-memory set to disk
- Функция QuickHashIntSet::saveToString() - This method returns a serialized version of the set
Коментарии
Attempts to delete an item from the set while iterating through it will fail.
<?php
$set = new QuickHashIntSet(8192);
$set->Add(100);
$set->Add(101);
$set->Add(102);
foreach ($set as $number) {
if ($number == 101) {
echo $set->delete($number)? '': 'FAILED';
}
}
?>