Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve time complexity of gaps() function #104

Merged
merged 1 commit into from
Dec 28, 2024

Conversation

neerajsi-msft
Copy link
Contributor

The RangeMap.gaps() function previously iterated
over all ranges prior to the query range before
returning the first overlapping gap. This results
in a worst-case O(n) time complexity per query.

Now the gaps() function reuses the overlaps() code to
get an iterator to the first overlapping range in O(log(n)) time.

Fixes issue #103.

The RangeMap.gaps() function previously iterated
over all ranges prior to the query range before
returning the first overlapping gap. This results
in a worst-case O(n) time complexity per query.

Now the gaps() function reuses the overlaps() code
to get an iterator to the first overlapping range
in O(log(n)) time.
@jeffparsons
Copy link
Owner

Thanks for this, Neeraj!

Any chance you'd be interested in applying the same treatment to RangeInclusiveMap?

@jeffparsons jeffparsons merged commit 160625c into jeffparsons:main Dec 28, 2024
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants