Search code examples
c++algorithmstl-algorithm

Needed: C++ class for maintaining a 1-dimensional list of extents


I am looking for a C++ class that can maintain a 1-dimensional list of extents.

Each extent is defined as a (start,len) pair.

I want to be able to add additional extents to the list and have them automatically consolidated. That is, if we have (0,5) and (10,5) in the list, and (5,5) is added, the new list should contain only (0,15).

Extents are never removed from the list.

Does anything like this exist?

Thanks.


Solution

  • Your are looking for Boost.Icl. It does exactly what you described.

    http://www.boost.org/doc/libs/1_52_0/libs/icl/doc/html/index.html