Algorithmic Solutions > LEDA > LEDA Guide > Geometry > Advanced Data Types for 2-Dimensional Geometry > Sets of Intervals


Sets of Intervals

The data type interval_set can be used to store a collection objects of an arbitrary type I together with closed intervals of double numbers as keys. The elements of a interval_set are of type is_item.

Strengths

  • operation to look up the item for a given interval of doubles
  • operation to find all items that intersect a given interval

Example

The following example shows how interval_set can be used. The information type in the example is string.

#include <LEDA/geo/interval_set.h>
#include <LEDA/core/string.h>

using namespace leda;

int main()
{
  interval_set<string> IS; 
           
  IS.insert(1,10,"a"); IS.insert(2,21,"b");
  IS.insert(3,4,"c");  IS.insert(120,120,"d");
  
  std::cout << "Lookup (3,4):";
  is_item isit=IS.lookup(3,4);
  if (isit!=nil) 
    std::cout << "(" << IS.left(isit) << "," 
              << IS.right(isit) << "," << IS.inf(isit) << ")\n";

  std::cout << "\nIntersection with (5,21):\n";
  list<is_item> L=IS.intersection(5,21);
  forall(isit,L) {
    std::cout << "(" << IS.left(isit) << "," 
              << IS.right(isit) << "," << IS.inf(isit) << ")\n";
  }
  return 0;
}

See also:

Sets

Two-Dimensional Dictionaries

Sets of Segments

Associating Information with Geometric Objects

Strings


Geometry

Geometry Algorithms

GeoWin


Manual Entries:

Manual Page Sets of Intervals

User Defined Parameter Types

LEDA Item Concept




Please send any suggestions, comments or questions to leda@algorithmic-solutions.com
© Copyright 2001-2003, Algorithmic Solutions Software GmbH