Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

IndexSet #1605

Copy link
Copy link
Open
Open
Copy link
@tolmasky

Description

@tolmasky
Issue body actions

It would be nice to have something like NSIndexSet. Essentially, you can think of it like the existing Range, but instead of it being an optimized List<int>, it is an optimized OrderedSet<int>. I was attempting to use Range this way earlier (so, for example, wanting Range(0,1000).concat(500,1500) to generate Range(0,1500)), but this is of course not the case.

IndexSets can be super useful in all sorts of different cases, from managing selection ranges (Cocoa's use) where a user is shift-clicking many items, to my current need where I have a set of overlapping time ranges and I am wanting to easily calculate the total time spent without double-counting overlaps.

Internally, IndexSets are implemented as a sorted array of Ranges. Removing a value can break an existing range into two ranges, while adding values could potentially unite previously disconnected ranges. I am not sure if there is a more efficient "persistent" strategy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.