« Ds\Collection::toArray
Ds\Hashable::equals »

The Hashable interface

(PECL ds >= 1.0.0)

はじめに

Hashable is an interface which allows objects to be used as keys. It’s an alternative to spl_object_hash(), which determines an object’s hash based on its handle: this means that two objects that are considered equal by an implicit definition would not be treated as equal because they are not the same instance.

hash() is used to return a scalar value to be used as the object's hash value, which determines where it goes in the hash table. While this value does not have to be unique, objects which are equal must have the same hash value.

equals() is used to determine if two objects are equal. It's guaranteed that the comparing object will be an instance of the same class as the subject.

インターフェイス概要

interface Ds\Hashable {
/* メソッド */
abstract public function equals(object $obj): bool
abstract public function hash(): mixed
}

目次

関連キーワード:
hash   Hashable   interface   equal   equals   instance   scalar   abstract   Collection   toArray   Structures   keys   It’s   handle   definition   because   table   While   unique   guaranteed   インターフェイス   mixed   whether
関連する関数・ページ:
ds-hashable.equals   ds-hashable.hash   function.hash-equals   function.hash-file   mhash.examples   ds-map.get