Michael de Kaste
02/22/2022, 9:38 AMMap<KClass<out T>, SomeType<T>>
currently we are filtering from a list in multiple factories which is an O(factories * N) problem. Ideally I just want to request a class type from a map and get the correct implementationTobias Berger
02/22/2022, 10:15 AMreified
overloads of get
and set
, so you wouldn't even need to put the class object in the arguments (depending on your use case).
A real Map
implementation will probably not work, at least not with the default get and put methods, because you can't override the interface methods with one that requires generics.
Here is an example implementation: https://pl.kotl.in/A2tG9y92UMichael de Kaste
02/22/2022, 10:46 AMephemient
02/22/2022, 11:22 AMkotlin.coroutines.CoroutineContext
associates from Key<Element>
to Element
. there's a few other projects out there like https://github.com/broo2s/typedmap. but if you just want a class->instance map, something simple like that example is fine.Joffrey
02/22/2022, 11:22 AMephemient
02/22/2022, 11:27 AM+
and composition of various `Element`s each of which will handle get
of its own key or delegate to the next context