Skip to content

Add View version of IndexMap and IndexSet #594

@sgued

Description

@sgued

IndexSet depends on the View type for IndexMap being available.

IndexMap is currently implemented with a CoreMaptype that looks like:

struct CoreMap<K, V, const N: usize> {
    entries: Vec<Bucket<K, V>, N>,
    indices: [Option<Pos>; N],
}

It is not possible to construct a View for this type like for Vec since the N would have to be erased twice.

We could solve that issue by "inlining" the indices into the entries:

struct CoreMap<K, V, const N: usize> {
    entries_indices: [(MaybeUninit<Bucket<K, V>>, Option<Pos>); N],
    len: usize,
}

Then only one N needs to be erased, and this can be implemented. However this requires changing the implementation significantly.

It might even be possible to get rid of the len field (I think an entry is initialised if and only if a index points to it, and only one index can point to it at a given time?).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions