Skip to content

Efficient get key/value by index in OrdMap/OrdSet #158

@alexforencich

Description

@alexforencich

Ordering is useful for iteration, but if there is a defined order then being able to efficiently jump into the middle of that at a defined point is vital. Think use cases like pagination and such. Unfortunately, OrdMap and OrdSet do not seem to support this natively. The only option seems to be iter().skip() or iter().nth(), which I think are O(n) as as far as I can tell they work by visiting every node in sequence. Seems to me like it should be possible to speed this up significantly. Potentially both iter.skip and iter.nth could be accelerated, as well as providing APIs to convert a key to an index and get a key/value by index.

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