Skip to content

[utils] Create abstraction over a sorted vec #1880

@cronokirby

Description

@cronokirby

In a few places, we need to map between a set of items and the indices [0..num_items] example 1, also the DKG / Reshare.

We do this with an ad-hoc abstraction in each case, but it would be useful to have a little abstraction in utils for this.

A simple way to do this would be to have the backing type contain a sorted vec of elements. You could easily create this from a slice or iterator, by collecting the elements, sorting them, and then removing duplicates. You could map an index to an item in O(1), by just indexing into the vector, and you could figure the index of an item with a binary search.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions