\begin{ccRefClass}{Segment_tree_k} \ccDefinition An object of the class \ccClassName\ is a $k$-dimensional segment tree that can store k-dimensional intervals of type \ccc{Interval}. The class allows to perform window queries, enclosing queries, and inverse range queries on the keys. The class \ccClassName\ is parameterized with a segment tree traits class \ccc{Traits} that defines, among other things, the type of the \ccc{Interval}. In order to perform an inverse range query, a range query of $\epsilon$ width has to be performed. We prefered not to offer an extra function for this sort of query, since the inverse range query is a special case of the range query. Furthermore, offering an inverse range query in the segment tree class implies offering this function also in the range tree class and having an extra item in the traits class that accesses the inverse range query point. \cgal\ provides traits class implementations that allow to use the segment tree with point classes from the \cgal\ kernel as keys. These classes are \ccc{CGAL::Range_segment_tree_traits_set_2}, \ccc{CGAL::Range_segment_tree_traits_set_3}, \ccc{CGAL::Segment_tree_traits_map_2} and \ccc{CGAL::Segment_tree_traits_map_3}. The concept RangeSegmentTreeTraits\_d defines the requirements that segment tree traits classes must fulfill. This allows the advanced user to develop further segment tree traits classes. \ccInclude{CGAL/Segment_tree_k.h} \ccTypes \ccNestedType{Traits}{the type of the segment tree traits class.} \ccTypedef{typedef Traits::Key Key;}{} \ccTypedef{typedef Traits::Interval Interval;}{} \ccCreationVariable{S} \ccCreation \ccConstructor{Segment_tree_k ();} {Introduces an empty segment tree \ccVar.} \ccConstructor{template < class ForwardIterator > Segment_tree_k (ForwardIterator first, ForwardIterator last);}% {Introduces a segment tree \ccVar\ and initializes it with the data in the range \ccc{[first, last)}. \ccPrecond \ccc{value_type(first) == Traits::Interval}.} \ccOperations \ccMethod{template < class ForwardIterator > void make_tree(ForwardIterator first, ForwardIterator last);}% {Introduces a segment tree \ccVar\ and initializes it with the data in the range \ccc{[first, last)}. This function can only be applied once on an empty segment tree. \ccPrecond \ccc{value_type(first) == Traits::Interval}.} \ccMethod{template < class OutputIterator > OutputIterator window_query(Interval window, OutputIterator out);}% {writes all intervals that have non empty intersection with interval \ccc{window} to the container where \ccc{out} points to, and returns an output iterator that points to the last location the function wrote to. \ccPrecond \ccc{value_type(out) == Traits::Interval}.} \ccMethod{template < class OutputIterator > OutputIterator enclosing_query(Interval window, OutputIterator out);}% {writes all intervals that enclose in the interval \ccc{window} to the container where \ccc{out} points to, and returns an output iterator that points to the last location the function wrote to. \ccPrecond \ccc{value_type(out) == Traits::Interval}.} \ccExample This example illustrates the use of the predefined segment tree on 3-dimensional interval data (with no value associated). After the definition of the traits type and tree type, some intervals are constructed and the tree is build according to the intervals. Then, a window query is performed and the query elements are given out. \begin{verbatim} #include #include #include typedef CGAL::Cartesian K; typedef CGAL::Range_segment_tree_set_traits_3 Traits; typedef CGAL::Segment_tree_3 Segment_tree_3_type; int main() { typedef Traits::Interval Interval; typedef Traits::Key Key; std::list InputList, OutputList; InputList.push_back(Interval(Key(1,5,7), Key(2,7,9))); InputList.push_back(Interval(Key(2,7,6), Key(3,8,9))); InputList.push_back(Interval(Key(6,9,5), Key(9,13,8))); InputList.push_back(Interval(Key(1,3,4), Key(3,9,8))); Segment_tree_3_type Segment_tree_3(InputList.begin(),InputList.end()); Interval a(Key(3,6,5), Key(7,12,8)); Segment_tree_3.window_query(a,std::back_inserter(OutputList)); std::list::iterator j = OutputList1.begin(); std::cout << "\n window_query (3,6,5),(7,12,8) \n"; while(j!=OutputList.end()){ std::cout << (*j).first.x() << "," << (*j).first.y() << ","; std::cout << (*j).first.z() <<", " << (*j).second.x() << ","; std::cout << (*j).second.y() << "," << (*j).second.z() << std::endl; j++; } } \end{verbatim} \end{ccRefClass}