korlibs / korlibs/korlibs-datastructure
Improve SortedMap support / interop
- Dominant language
- Kotlin
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
The class `com.soywiz.kds.SortedMap` should be better integrated into the collection framework.
Improvements I think would be necessary:
### 1. A new name
There is already a `java.util.SortedMap` interface if you're working with Kotlin/JVM. This can lead to a lot of confusing naming clashes, especially when implementing extensions / toplevels (see below). Two classes with essentially the same purpose (but still fundamentally different, see 2) shouldn't be named the same, or else it will lead to tedious naming collisions
### 2. Implement the `kotlin.collections.Map` interface
It would help a lot if `com.soywiz.SortedMap` would implement the `Map` interface from the Kotlin stdlib, because that would allow for convenient re-use of stdlib / third-party (extension) functions. Since `SortedMap` essentially provides `Map` functionality, it not implementing that interface is kind of counter-intuitive.
### 3. Provide stdlib-like utilities
For every collection in the stdlib, there are also convenience methods for instantiating or converting to that collection type. Similar to how it works for e.g. `List` or `Map`, there should be at least a `sortedMapOf()` and a `Map.toSortedMap()` function. Note that because of 1, this will introduce even worse naming confusions, since the Kotlin stdlib already provides these two functions on the JVM. In order to stick to the common naming scheme of the stdlib, `com.soywiz.kds.SortedMap` would need to be renamed.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the com.soywiz.kds.SortedMap class and inspect how it currently integrates with Kotlin collections. Define the naming, Map-interface, sortedMapOf(), and Map.toSortedMap() changes described in the issue, then verify compatibility with existing JVM naming and extension-function behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- developer-experience
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100