Skip to content

Convenience functions elemAt and deleteAt #46

@tysonzero

Description

@tysonzero

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions