hey codeforcers, i decided to do something new and decide to learn python so i need some help here. How can i use an equivalent to c++ set stl in python and similarly how can i use an equivalent to c++ map stl , the dict and set() are not sorted, plz help me.It would be great if someone could provide a usful link or something so that i can learn those things.
std::set
andstd::map
and their multi versions can be provided by copy/pasting this: https://bitbucket.org/mozman/bintrees/src/e90631d7139c910394ae3f8f620246a8a9a93fdf/bintrees/rbtree.py?at=default&fileviewer=file-view-default (This comes from the pythonbintrees
library)std::unordered_set
->set
std::unordered_map
->map
std::bitset
-> no good implementations that I know of; the bitset library doesn't support a bunch of operators and python doesn't have unsigned ints. Using a regularint
might work if you're really careful (They're arbitrarily large).std::vector
-> list lolstd::deque
andstd::queue
->collections.deque
std::priority_queue
->heapq
Unfortunately, getting std::set/std::map is not as easy as just copying and pasting the source code by the link above as it imports also abctree.py and treeslice.py. Their total length is 1100+ lines of code.