Skip to content

Designing out duplicates items in the timeline #1533

Open
@poljar

Description

@poljar

It would likely make sense to solve the de-duplication via a design change. We should switch towards using a HashMap and a Vec for the Timeline:

struct Timeline {
    items: HashMap<EventId, TimelineItem>,
    item_positions: Vec<EventId>,
}

Note that the exact types don't need to be Vec and HashMap but they should have properties that are equivalent to those two.

This would prevent us from ever inserting items that have the same EventId into the timeline. Another nice advantage of this approach is that, if we have an operation that requires us to find the event by its ID, we can find the event in O(1) time instead of O(N) where N is the number of elements in the timeline.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions