TypeOf(T) -- Fix you generic Map<K,V> issues

Monkey Forums/Monkey Code/TypeOf(T) -- Fix you generic Map<K,V> issues

Pharmhaus(Posted 2015) [#1]
Hi,
The following codes fixes all your problems when you try to use maps/lists/sets + Generics.
I hope it gets implemented into MX one day.




ziggy(Posted 2015) [#2]
What's the usage of this? Can't see where I would be using this?


Pharmhaus(Posted 2015) [#3]
The default Map<K,V> cannot be used to stored values because CompareTo(..) is abstract.
So you need a concrete implementation like IntMap, StringMap, etc.
When you write a generic class / method / function and you like to use a map you don't now which of kind of map you need (because of T).
Same for Set<T> and if you like to sort also for List<T> and Stack<T>.


Samah(Posted 2015) [#4]
@Pharmhaus: Same for Set<T> and if you like to sort also for List<T> and Stack<T>.

This is why I made DiddyStack, DiddyList, and DiddySet. They extend the base library classes and handle all the sorting/comparison stuff for you. They can also be interchangeable in some situations.
https://code.google.com/p/diddy/source/browse/src/diddy/diddystack.monkey