pytreemapΒΆ
Contents:
pytreemap
is a Python implementation of Java TreeMap/TreeSet.
Most of the TreeMap/TreeSet APIs are implemented with some exceptions.
Please go to the TreeMap section or TreeSet section for
the full list of implemented APIs.
The underlying data structure is the Red-Black tree and
offers \(O(\text{log}\ n)\) time complexity for
search (get()
), insert (put()
),
delete (remove()
), and many other operations.
Same as Java TreeMap/TreeSet, this implementation is NOT synchronized, you MUST do synchronization yourself in multi-threaded applications.
The iterators returned by the TreeMap/TreeSet are fail-fast, meaning that an exception is thrown as soon as a structural change to the TreeMap/TreeSet is discovered.
Note
You should not rely on the fail-fast behaviour while testing your programs correctness. There is no guarantee that structural changes to the TreeMap/TreeSet are always caught.
Source code is available on GitHub.