Reputation: 69865
From a strictly implementation and computer science point of view how would you classify the Php array datastructure? Is it an associative array? a hash? a dictionary? ... ?
Upvotes: 2
Views: 519
Reputation: 117567
It depends on what you want to define really. A dictionary or map refers to the behaviour of the datatype, while a hashmap refers to a specific implementation hereof. The term array is a bit tinted - Strictly speaking, it refers to a concrete implementation, whereas a list is a generic term that refers to any array-like datatype. It's however quite common to use array as a synonym for list.
Upvotes: 0
Reputation: 4589
Well, it depends on how you wish to classify it. I'd opt for classification by the performance of operations.
For example, a true array in Computer Science terms has an O(1) lookup time, while a linked list has an O(n) lookup time. Insertion and deletion are O(1) in a linked list while they are O(n) in an array.
I am not sure what the actual performance of a PHP array is, but if you measure a few of the elementary operations on them and compare them with what's expected from the 'true Computer Science datastructures' you should be able to classify it.
Upvotes: 3
Reputation: 57825
From the PHP manual:
An array in PHP is actually an ordered map. A map is a type that associates values to keys. This type is optimized for several different uses; it can be treated as an array, list (vector), hash table (an implementation of a map), dictionary, collection, stack, queue, and probably more.
Upvotes: 8
Reputation: 183
It's a bit difficult to define it in my opinion. Although, I think I would classify it as an associative array since most of the defined operations for an associative array are available on PHP arrays.
Upvotes: 1