As a java guy learning Python I'm trying to find similarities between the languages. I found collections module in python and also built-in structures similar to java collections framework (covered by this post What is/are the Python equivalent(s) to the Java Collections Framework?).
But I haven't found analogue of a TreeMap - a map based on red-black tree - a map sorted by keys and guaranteed log(n) time cost for the get, put and remove operations
Is there such a structure in Python 3.x?
looks like I've found an answer: https://pypi.org/project/sortedmap/. As author mentions it's backed by red-black tree.
Also in order to provide SortedMap functionality the following lib can be used http://www.grantjenks.com/docs/sortedcontainers/introduction.html . It's not using red-black tree but it's using a list of keys sorted using bisect module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With