synt's blog

By synt, history, 43 hours ago, In English

What do you guys use in Python for multiset? Tried using heap but it doesnt have O(logN) deletions

  • Vote: I like it
  • 0
  • Vote: I do not like it

»
40 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

afaik .. nothing

relevant SO thread

»
40 hours ago, # |
  Vote: I like it 0 Vote: I do not like it

You can use the sorted list or treap from here

»
39 hours ago, # |
Rev. 3   Vote: I like it 0 Vote: I do not like it

use a sorted set of tuples (item, unique value). Any unique value works, I usually just use a variable and increment it after each insertion.