Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6770065
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:16:05+00:00 2026-05-26T15:16:05+00:00

What I want to do is handling interval efficiently. For example, in my example,

  • 0

What I want to do is handling interval efficiently. For example, in my example, intervals are like the following:

[10, 20], [15, 25], [40, 100], [5, 14]

Intervals are closed and integers, and some of intervals may be ovelapped. I want to find overlapped intervals for a given query efficiently. For example, if [16, 22] is given:

[10, 20], [15, 25]

The above intervals should be computed as overalpped intervals.

I’m currently writing an interval tree based on Red-Black Tree (reference: CLRS, Introduction to Algorithms). Although finding all overlapped intervals can be O(n), the running time should be faster. Note that intervals can be deleted and inserted.


However, I just found that Boost has interval_map and interval_set:
http://www.boost.org/doc/libs/1_46_1/libs/icl/doc/html/index.html

I tried it, but the behavior is very strange for me. For example, if [2, 7] is inserted first and then [3, 8] is inserted, then the resulting map will have [2, 3), [3, 7], and (7, 8]. That is, when a new interval is inserted, splitting is automatically done.

Can I turn off this feature? Or, Boost’s interval_map is right for my purpose?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T15:16:05+00:00Added an answer on May 26, 2026 at 3:16 pm

    You asked for a data structure that could find overlaps efficiently. This does so, by storing overlaps in the data structure. Now you seem to be complaining that it has done so.

    This example explains the logic:

    typedef std::set<string> guests;
    interval_map<time, guests> party;
    party += make_pair(interval<time>::right_open(time("20:00"), time("22:00")),
    guests("Mary"));
    party += make_pair(interval<time>::right_open(time("21:00"), time("23:00")),
    guests("Harry")); 
    // party now contains
    [20:00, 21:00)->{"Mary"} 
    [21:00, 22:00)->{"Harry","Mary"} //guest sets aggregated on overlap
    [22:00, 23:00)->{"Harry"}
    

    When you add two overlapping intervals, you actually create three intervals with distinct properties. The overlap is in both original intervals, make it a logically distinct interval from either of the original intervals. And the two original intervals now span times with different properties (some that overlap the original, some that don’t). This splitting makes it efficient to find overlaps, since they are their own intervals in the map.

    In any event, Boost does allow you to select the interval combining style. So if you want to force a structure that makes it harder to find overlaps, you can do so.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use custom exception handling, for example instead of using (Exception ex)
I have VB6 application , I want to put some good error handling finction
I want to create a background Thread handling some tasks (Runnable) and executing them
I want to put some error handling in my code. I can not figure
I want to ask about what your approach looks like handling a situation like
I am using Akka FSM for handling state in my Actor. I want some
I want to implement the handling of an additional swipe gesture in my UITableViewController.
I want to go beyond the default error handling given in ASP mvc. I
I want to conform my site's string handling to support other languages per UTF-8.
I want to make a general error handling package that should be called from

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.