a type cannot be both Map and List #133
Labels
No labels
bug
discussion
documentation
duplicate
ignore
new feature
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/gms-gods#133
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
because both
MapandListdefine aGetwith different parameters. Ideally I want something like:Use case is I want to have a different
LinkedHashMapthat's not onlyenumerable, but also allow random access to the index. It makes sense for this hypothetical map to also implementList, but right now that's not possible.@kahing not sure if I understood, but map and list are different in many aspects. If you would like to treat the keys as a list, i.e. ordered collection (list) by insertion order, you can use the LinkedHashMap. So that would be insertion-ordering, otherwise, I am not sure what the first or n-th element is in a map? If you look at Golang's native map, the keys are shuffled around when you iterate on the keys, i.e. seemingly random ordering... and they have done that for a good reason.
For the specific use case you mentioned, perhaps you can achieve that simply by using two data structures. One is a map and the other one is a list, at least that is exactly how such data structure would be implemented. Then you either use the map or list depending on the method of retrieval (get-by-key or get-by-index).
It would help if you could point me out to a data structure (can be in another language) that has this functionality that you are asking for, so I can get ideas from there... if at least, how to name it :D