1. Features
Supports typical key->value query.
Can be used as an array.
Adding and deleting nodes is O(1) complexity.
Key supports mixed types: there are related array index arrays at the same time.
Value supports mixed types.
Supports linear traversal: such as foreach.
2. Example
typedef struct _hashtable { uint nTableSize; //The length of the table, not the number of elements uint nTableMask; //The mask of the table, always equal to nTableSize-1 uint nNumOfElements; //The number of stored elements ulong nNextFreeElement; //Points to the next empty element position Bucket *pInternalPointer; //During the foreach loop, it is used to record the currently traversed element position Bucket *pListHead; Bucket *pListTail; Bucket **arBuckets;//Stored element array dtor_func_t pDestructor;//Destructor zend_bool persistent;//Whether it is persisted. From this we can find that PHP arrays can be persisted in memory without reloading each request. unsigned char nApplyCount; zend_bool bApplyProtection; }HashTable;
The above are the characteristics of hash table in PHP. I hope it will be helpful to everyone.