3 ms·
On the list vs. set... This is an "easy" one if you just stick to the standard CS def, or you just know a language that has a clearly defined library offering t
by lrobb 15y ago
On the list vs. set... This is an "easy" one if you just stick to the standard CS def, or you just know a language that has a clearly defined library offering that... But in PHP, there's technically no difference between a list and a set: 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. As array values can be other arrays, trees and multidimensional arrays are also possible.
- icebraining 15y agoBut in PHP, there's technically no difference between a list and a set Sure there is. In a set, you can't have repeated values. PHP arrays can. Of course, you can implement a set using a PHP array.
- lrobb 15y agoI'm well aware of the difference between a set and a list. My point, which was apparently lost, is that the underlying implementation of these structures is the same in PHP.