Lists and maps are very useful, but VB6 had a construct that was even better, the Collection.
Basically, it was like a combination of a map and a list, with all the features of both. Items could be retrieved by index or by key, it had an order, you could insert objects at any position and so on.
This is immensely useful in many situations, and the list and the map don't really measure up. The list doesn't have keys, the map doesn't have a reliable order and the ability to insert items at a specific position, and the lack of any means to combine these two blocks many elegant solutions.
For example, writing a cache manager using collections is trivial. Just look if the key is in the collection. If it is, retrieve data from the collection, then move it to the start of the collection. If not, fetch data from outside the cache, then add it to the start. If the cache is larger than it should be, discard the last item.
A similar problem where a collection would be useful is a playlist. I'm currently writing an implementation, where the GUI needs to get data from the playlist by key, yet the playlist needs to maintain and modify the order of the list.
Sure, it's possible to connect a map and a list with some code, but it's kind of fiddly and error prone, and it would be better to have it properly package in a Collection data type.
Basically, it was like a combination of a map and a list, with all the features of both. Items could be retrieved by index or by key, it had an order, you could insert objects at any position and so on.
This is immensely useful in many situations, and the list and the map don't really measure up. The list doesn't have keys, the map doesn't have a reliable order and the ability to insert items at a specific position, and the lack of any means to combine these two blocks many elegant solutions.
For example, writing a cache manager using collections is trivial. Just look if the key is in the collection. If it is, retrieve data from the collection, then move it to the start of the collection. If not, fetch data from outside the cache, then add it to the start. If the cache is larger than it should be, discard the last item.
A similar problem where a collection would be useful is a playlist. I'm currently writing an implementation, where the GUI needs to get data from the playlist by key, yet the playlist needs to maintain and modify the order of the list.
Sure, it's possible to connect a map and a list with some code, but it's kind of fiddly and error prone, and it would be better to have it properly package in a Collection data type.