multiset
multiset copied to clipboard
Convenience functions elemAt and deleteAt
Data.Set
has:
elemAt :: Int -> Set a -> a -- O(log n)
deleteAt :: Int -> Set a -> Set a -- O(log n)
It would be nice to have similar functions for MultiSet
:
elemAt :: Int -> MultiSet a -> a -- O(n)
distinctElemAt :: Int -> MultiSet a -> a -- O(log n)
deleteAt :: Int -> MultiSet a -> MultiSet a -- O(n)
distinctDeleteAt :: Int -> MultiSet a -> MultiSet a -- O(log n)
distinctDeleteManyAt :: Int -> Occur -> MultiSet a -> MultiSet a -- O(log n)
distinctDeleteAllAt :: Int -> MultiSet a -> MultiSet a -- O(log n)
I'm mostly interested in elemAt
for my purposes (using MultiSet
as a bag to randomly take from).
You could theoretically bring down all the complexities to O(log n)
but it would require changing the internal structure.