Ordered Data Structures


I came from C++ and fell in love with kotlin. I used the C++ stdlib a lot. I have really been wanted to reach for map
and unordered_map and set that I know and love from the std template library.

Kotlin has list, set, and map, and they all preserve the order of insertion. Which those are nice and do what you need
most of the time, but I need data structures that maintain order. I also don’t really like kotlin’s map interface.
iterators of the map convert the whole thing to a set and then iterate over the set.

Right now I have a tree interface I am much more happy with. It provides a collection, so it can be iterated over
without being converted to a set. The only implementation is a basic unbalanced binary search tree that is not thread
safe (so I have some work to do)
. The next one I am going to work on is a red black tree. then I will make a tree that is a set, so no keys, just
values. Then an ordered list. Actually I have already done an ordered list once. Kotlin stdlibrary already provides most
of the implementation. I really confuses me why they didn’t just make an ordered list collection. So I might do that one
soon.

Install

Maybe later I will try hooking up jitpack, but for now. Just clone the repo. Build the library with gradle and then use
gradle’s publish to mavenlocal. Then in a project you want to consume the library with. Add MavenLocal() repo. And add a
dependency on the library with
implementation("com.xingpeds.dataStructures:DataStructures:1.0-SNAPSHOT")

GitHub

View Github