• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*-----------------------------------------------------------------------------+
2 Copyright (c) 2008-2012: Joachim Faulhaber
3 +------------------------------------------------------------------------------+
4    Distributed under the Boost Software License, Version 1.0.
5       (See accompanying file LICENCE.txt or copy at
6            http://www.boost.org/LICENSE_1_0.txt)
7 +-----------------------------------------------------------------------------*/
8 #ifndef LIBS_ICL_TEST_TEST_INTERVAL_MAP_SHARED_HPP_JOFA_081005
9 #define LIBS_ICL_TEST_TEST_INTERVAL_MAP_SHARED_HPP_JOFA_081005
10 
11 #include "portability.hpp"
12 
13 template
14 <
15 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
16     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
17 #else
18     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
19 #endif
20     class T, class U
21 >
interval_map_fundamentals_4_ordered_types()22 void interval_map_fundamentals_4_ordered_types()
23 {
24     typedef IntervalMap<T,U> IntervalMapT;
25     typedef typename IntervalMapT::interval_type   IntervalT;
26     typedef typename IntervalMapT::size_type       size_T;
27 
28     // ordered types is the largest set of instance types.
29     // Because we can not generate values via incrementation for e.g. string,
30     // we are able to test operations only for the most basic values
31     // identity_element (0, empty, T() ...) and unit_element.
32 
33     T v0 = boost::icl::identity_element<T>::value();
34     T v1 = unit_element<T>::value();
35     IntervalT I0_0I(v0);
36     IntervalT I1_1I(v1);
37 #ifndef BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
38     IntervalT I0_1I(v0, v1, interval_bounds::closed());
39 #else
40     IntervalT I0_1I = icl::interval<T>::closed(v0, v1);
41 #endif
42     U u1 = unit_element<U>::value();
43 
44     //-------------------------------------------------------------------------
45     //empty set
46     //-------------------------------------------------------------------------
47     BOOST_CHECK_EQUAL(IntervalMapT().empty(), true);
48     BOOST_CHECK_EQUAL(icl::is_empty(IntervalMapT()), true);
49     BOOST_CHECK_EQUAL(cardinality(IntervalMapT()), boost::icl::identity_element<size_T>::value());
50     BOOST_CHECK_EQUAL(IntervalMapT().size(), boost::icl::identity_element<size_T>::value());
51     BOOST_CHECK_EQUAL(icl::size(IntervalMapT()), boost::icl::identity_element<size_T>::value());
52     BOOST_CHECK_EQUAL(interval_count(IntervalMapT()), 0);
53     BOOST_CHECK_EQUAL(IntervalMapT().iterative_size(), 0);
54     BOOST_CHECK_EQUAL(iterative_size(IntervalMapT()), 0);
55     BOOST_CHECK_EQUAL(IntervalMapT(), IntervalMapT());
56 
57     IntervalT mt_interval = boost::icl::identity_element<IntervalT >::value();
58     BOOST_CHECK_EQUAL(mt_interval, IntervalT());
59     typename IntervalMapT::value_type mt_u1 = make_pair(mt_interval, u1);
60     IntervalMapT mt_map = boost::icl::identity_element<IntervalMapT >::value();
61     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
62 
63     //adding emptieness to emptieness yields emptieness ;)
64     mt_map.add(mt_u1).add(mt_u1);
65     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
66     mt_map.insert(mt_u1).insert(mt_u1);
67     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
68     (mt_map += mt_u1) += mt_u1;
69     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
70     BOOST_CHECK_EQUAL(hull(mt_map), boost::icl::identity_element<IntervalT >::value());
71 
72     //subtracting emptieness
73     mt_map.subtract(mt_u1).subtract(mt_u1);
74     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
75 
76     mt_map.erase(mt_interval).erase(mt_interval);
77     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
78     (mt_map -= mt_u1) -= mt_u1;
79     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
80 
81     //subtracting elements form emptieness
82     typename IntervalMapT::domain_mapping_type v0_u1 = make_pair(v0,u1);
83     typename IntervalMapT::domain_mapping_type v1_u1 = make_pair(v1,u1);
84     //mt_map.subtract(make_pair(v0,u1)).subtract(make_pair(v1,u1));
85     mt_map.subtract(v0_u1).subtract(v1_u1);
86     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
87     mt_map.erase(v0_u1).erase(v1_u1);
88     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
89     (mt_map -= v0_u1) -= v1_u1;
90     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
91 
92     //subtracting intervals form emptieness
93     typename IntervalMapT::segment_type I0_0I_u1 = make_pair(I0_0I,u1);
94     typename IntervalMapT::segment_type I0_1I_u1 = make_pair(I0_1I,u1);
95     typename IntervalMapT::segment_type I1_1I_u1 = make_pair(I1_1I,u1);
96     mt_map.subtract(I0_1I_u1).subtract(I1_1I_u1);
97     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
98     mt_map.erase(I0_1I_u1).erase(I1_1I_u1);
99     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
100     (mt_map -= I0_1I_u1) -= I1_1I_u1;
101     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
102 
103     mt_map.erase(I0_1I).erase(I1_1I);
104     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
105 
106     //insecting emptieness
107     (mt_map &= mt_u1) &= mt_u1;
108     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
109     (mt_map &= mt_interval) &= mt_interval;
110     BOOST_CHECK_EQUAL(mt_map, IntervalMapT());
111 
112 
113 
114     //-------------------------------------------------------------------------
115     //unary set
116     //-------------------------------------------------------------------------
117     IntervalMapT single_I0_0I_u1_from_element(v0_u1);
118     IntervalMapT single_I0_0I_u1_from_interval(I0_0I_u1);
119     IntervalMapT single_I0_0I_u1(single_I0_0I_u1_from_interval);
120 
121     BOOST_CHECK_EQUAL(single_I0_0I_u1_from_element, single_I0_0I_u1_from_interval);
122     BOOST_CHECK_EQUAL(single_I0_0I_u1_from_element, single_I0_0I_u1);
123     BOOST_CHECK_EQUAL(hull(single_I0_0I_u1), I0_0I);
124     BOOST_CHECK_EQUAL(hull(single_I0_0I_u1).lower(), I0_0I.lower());
125     BOOST_CHECK_EQUAL(hull(single_I0_0I_u1).upper(), I0_0I.upper());
126 
127     IntervalMapT single_I1_1I_u1_from_element(v1_u1);
128     IntervalMapT single_I1_1I_u1_from_interval(I1_1I_u1);
129     IntervalMapT single_I1_1I_u1(single_I1_1I_u1_from_interval);
130 
131     BOOST_CHECK_EQUAL(single_I1_1I_u1_from_element, single_I1_1I_u1_from_interval);
132     BOOST_CHECK_EQUAL(single_I1_1I_u1_from_element, single_I1_1I_u1);
133 
134     IntervalMapT single_I0_1I_u1_from_interval(I0_1I_u1);
135     IntervalMapT single_I0_1I_u1(single_I0_1I_u1_from_interval);
136 
137     BOOST_CHECK_EQUAL(single_I0_1I_u1_from_interval, single_I0_1I_u1);
138     BOOST_CHECK_EQUAL(hull(single_I0_1I_u1), I0_1I);
139     BOOST_CHECK_EQUAL(hull(single_I0_1I_u1).lower(), I0_1I.lower());
140     BOOST_CHECK_EQUAL(hull(single_I0_1I_u1).upper(), I0_1I.upper());
141 
142     //contains predicate
143     BOOST_CHECK_EQUAL(icl::contains(single_I0_0I_u1, v0), true);
144     BOOST_CHECK_EQUAL(icl::contains(single_I0_0I_u1, v0_u1), true);
145     BOOST_CHECK_EQUAL(icl::contains(single_I0_0I_u1, I0_0I_u1), true);
146 
147     BOOST_CHECK_EQUAL(icl::contains(single_I1_1I_u1, v1), true);
148     BOOST_CHECK_EQUAL(icl::contains(single_I1_1I_u1, v1_u1), true);
149     BOOST_CHECK_EQUAL(icl::contains(single_I1_1I_u1, I1_1I_u1), true);
150 
151     BOOST_CHECK_EQUAL(icl::contains(single_I0_1I_u1, v0), true);
152     BOOST_CHECK_EQUAL(icl::contains(single_I0_1I_u1, I0_1I_u1), true);
153     BOOST_CHECK_EQUAL(icl::contains(single_I0_1I_u1, v1), true);
154     BOOST_CHECK_EQUAL(icl::contains(single_I0_1I_u1, I1_1I_u1), true);
155 
156     BOOST_CHECK_EQUAL(icl::contains(single_I0_1I_u1, single_I0_0I_u1), true);
157     BOOST_CHECK_EQUAL(icl::contains(single_I0_1I_u1, single_I1_1I_u1), true);
158     BOOST_CHECK_EQUAL(icl::contains(single_I0_1I_u1, single_I0_1I_u1), true);
159 
160     BOOST_CHECK_EQUAL(cardinality(single_I0_0I_u1), unit_element<size_T>::value());
161     BOOST_CHECK_EQUAL(single_I0_0I_u1.size(), unit_element<size_T>::value());
162     BOOST_CHECK_EQUAL(interval_count(single_I0_0I_u1), 1);
163     BOOST_CHECK_EQUAL(single_I0_0I_u1.iterative_size(), 1);
164     BOOST_CHECK_EQUAL(iterative_size(single_I0_0I_u1), 1);
165 
166 }
167 
168 template
169 <
170 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
171     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
172 #else
173     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
174 #endif
175     class T, class U
176 >
interval_map_ctor_4_bicremental_types()177 void interval_map_ctor_4_bicremental_types()
178 {
179     typedef IntervalMap<T,U> IntervalMapT;
180     typedef typename IntervalMapT::interval_type   IntervalT;
181 
182     T v4 = make<T>(4);
183     U u2 = make<U>(2);
184     IntervalT I4_4I(v4);
185     typename IntervalMapT::domain_mapping_type v4_u2(v4,u2);
186     typename IntervalMapT::value_type I4_4I_u2(I4_4I,u2);
187 
188     IntervalMapT _I4_4I_u2;
189     BOOST_CHECK_EQUAL( _I4_4I_u2.empty(), true );
190     IntervalMapT _I4_4I_u2_1;
191     IntervalMapT _I4_4I_u2_2;
192     IntervalMapT _I4_4I_u2_3;
193     _I4_4I_u2   += v4_u2;
194     _I4_4I_u2_1 += I4_4I_u2;
195     BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_1 );
196     _I4_4I_u2_2.add(v4_u2);
197     BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_2 );
198     _I4_4I_u2_3.add(I4_4I_u2);
199     BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_3 );
200 
201     _I4_4I_u2.clear();
202     _I4_4I_u2.add(I4_4I_u2).add(I4_4I_u2);
203     IntervalMapT _I4_4I_u4(make_pair(I4_4I, make<U>(4)));
204     BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u4 );
205 
206     _I4_4I_u2.clear();
207     _I4_4I_u2.insert(I4_4I_u2).insert(I4_4I_u2);
208     BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_1 );
209 
210     BOOST_CHECK_EQUAL( cardinality(_I4_4I_u2), unit_element<typename IntervalMapT::size_type>::value()  );
211     BOOST_CHECK_EQUAL( _I4_4I_u2.size(),       unit_element<typename IntervalMapT::size_type>::value()  );
212     BOOST_CHECK_EQUAL( interval_count(_I4_4I_u2),   1  );
213     BOOST_CHECK_EQUAL( _I4_4I_u2.iterative_size(),  1  );
214     BOOST_CHECK_EQUAL( iterative_size(_I4_4I_u2),   1  );
215 
216     if(has_dynamic_bounds<IntervalT>::value)
217     {
218         BOOST_CHECK_EQUAL( hull(_I4_4I_u2).lower(), v4 );
219         BOOST_CHECK_EQUAL( hull(_I4_4I_u2).upper(), v4 );
220     }
221 
222     IntervalMapT _I4_4I_u2_copy(_I4_4I_u2);
223     IntervalMapT _I4_4I_u2_assigned;
224     _I4_4I_u2_assigned = _I4_4I_u2;
225     BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_copy );
226     BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_assigned );
227 
228     _I4_4I_u2_assigned.clear();
229     BOOST_CHECK_EQUAL( true,   _I4_4I_u2_assigned.empty() );
230 
231     _I4_4I_u2_assigned.swap(_I4_4I_u2_copy);
232     BOOST_CHECK_EQUAL( true,   _I4_4I_u2_copy.empty() );
233     BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_assigned );
234 }
235 
236 
237 template
238 <
239 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
240     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
241 #else
242     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
243 #endif
244     class T, class U
245 >
interval_map_add_sub_4_bicremental_types()246 void interval_map_add_sub_4_bicremental_types()
247 {
248     typedef IntervalMap<T,U> IntervalMapT;
249     typedef typename IntervalMapT::interval_type   IntervalT;
250 
251     T v0 = make<T>(0);
252     T v5 = make<T>(5);
253     T v6 = make<T>(6);
254     T v9 = make<T>(9);
255     U u1 = make<U>(1);
256 #ifndef BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
257     IntervalT I5_6I(v5,v6, interval_bounds::closed());
258     IntervalT I5_9I(v5,v9, interval_bounds::closed());
259     IntervalT I0_9I = IntervalT::closed(v0, v9);
260 #else
261     IntervalT I5_6I = icl::interval<T>::closed(v5,v6);
262     IntervalT I5_9I = icl::interval<T>::closed(v5,v9);
263     IntervalT I0_9I = icl::interval<T>::closed(v0,v9);
264 #endif
265     typename IntervalMapT::domain_mapping_type v0_u1 = make_pair(v0, u1);
266     typename IntervalMapT::domain_mapping_type v9_u1 = make_pair(v9, u1);
267     typename IntervalMapT::value_type I5_6I_u1 = make_pair(I5_6I, u1);
268     typename IntervalMapT::value_type I5_9I_u1 = make_pair(I5_9I, u1);
269 
270     BOOST_CHECK_EQUAL( IntervalMapT(I5_6I_u1).add(v0_u1).add(v9_u1),
271                        IntervalMapT().add(v9_u1).add(I5_6I_u1).add(v0_u1) );
272 
273     IntervalMapT map_A = IntervalMapT(I5_6I_u1).add(v0_u1).add(v9_u1);
274     IntervalMapT map_B = IntervalMapT().insert(v9_u1).insert(I5_6I_u1).insert(v0_u1);
275     BOOST_CHECK_EQUAL( map_A, map_B );
276     BOOST_CHECK_EQUAL( hull(map_A), I0_9I );
277     BOOST_CHECK_EQUAL( hull(map_A).lower(), I0_9I.lower() );
278     BOOST_CHECK_EQUAL( hull(map_A).upper(), I0_9I.upper() );
279 
280     IntervalMapT map_A1 = map_A, map_B1 = map_B,
281                  map_A2 = map_A, map_B2 = map_B;
282 
283     map_A1.subtract(I5_6I_u1).subtract(v9_u1);
284     map_B1.erase(v9_u1).erase(I5_6I_u1);
285     BOOST_CHECK_EQUAL( map_A1, map_B1 );
286 
287     map_B1 = map_B;
288     map_B2.erase(v9).erase(I5_6I);
289     BOOST_CHECK_EQUAL( map_A1, map_B2 );
290 
291     map_A2.subtract(I5_9I_u1);
292     map_B2.erase(I5_9I);
293     BOOST_CHECK_EQUAL( map_A2, map_B2 );
294 }
295 
296 template
297 <
298 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
299     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
300 #else
301     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
302 #endif
303     class T, class U
304 >
interval_map_distinct_4_bicremental_types()305 void interval_map_distinct_4_bicremental_types()
306 {
307     typedef IntervalMap<T,U> IntervalMapT;
308     typedef typename IntervalMap<T,U>::size_type       size_T;
309     T v1 = make<T>(1);
310     T v3 = make<T>(3);
311     T v5 = make<T>(5);
312     U u1 = make<U>(1);
313     typename IntervalMapT::domain_mapping_type v1_u1(v1,u1);
314     typename IntervalMapT::domain_mapping_type v3_u1(v3,u1);
315     typename IntervalMapT::domain_mapping_type v5_u1(v5,u1);
316 
317     size_T s3 = make<size_T>(3);
318 
319     IntervalMapT is_1_3_5;
320     is_1_3_5.add(v1_u1).add(v3_u1).add(v5_u1);
321 
322     BOOST_CHECK_EQUAL( cardinality(is_1_3_5),      s3 );
323     BOOST_CHECK_EQUAL( is_1_3_5.size(),             s3 );
324     BOOST_CHECK_EQUAL( interval_count(is_1_3_5),   3 );
325     BOOST_CHECK_EQUAL( is_1_3_5.iterative_size(),   3 );
326     BOOST_CHECK_EQUAL( iterative_size(is_1_3_5),   3 );
327 }
328 
329 template
330 <
331 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
332     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
333 #else
334     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
335 #endif
336     class T, class U
337 >
interval_map_distinct_4_bicremental_continuous_types()338 void interval_map_distinct_4_bicremental_continuous_types()
339 {
340 #ifndef BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
341 
342     typedef IntervalMap<T,U> IntervalMapT;
343     typedef typename IntervalMapT::size_type       size_T;
344     typedef typename IntervalMapT::difference_type diff_T;
345     T v1 = make<T>(1);
346     T v3 = make<T>(3);
347     T v5 = make<T>(5);
348     U u1 = make<U>(1);
349     typename IntervalMapT::domain_mapping_type v1_u1(v1,u1);
350     typename IntervalMapT::domain_mapping_type v3_u1(v3,u1);
351     typename IntervalMapT::domain_mapping_type v5_u1(v5,u1);
352 
353     size_T s3 = make<size_T>(3);
354     diff_T d0 = make<diff_T>(0);
355     diff_T d2 = make<diff_T>(2);
356 
357     IntervalMapT is_1_3_5;
358     is_1_3_5.add(v1_u1).add(v3_u1).add(v5_u1);
359 
360     BOOST_CHECK_EQUAL( cardinality(is_1_3_5),      s3 );
361     BOOST_CHECK_EQUAL( is_1_3_5.size(),            s3 );
362     icl::length(is_1_3_5);
363     BOOST_CHECK_EQUAL( icl::length(is_1_3_5),      d0 );
364     BOOST_CHECK_EQUAL( interval_count(is_1_3_5),   3 );
365     BOOST_CHECK_EQUAL( is_1_3_5.iterative_size(),  3 );
366     BOOST_CHECK_EQUAL( iterative_size(is_1_3_5),   3 );
367 
368 
369     IntervalMapT is_123_5;
370     is_123_5 = is_1_3_5;
371     //OPROM: open problem: Ambiguity resolving value_type and mapping_type for overloaded o= operators.
372     //is_123_5 += make_pair(IntervalT::open(v1,v3),u1);                 //error C2593: 'operator +=' is ambiguous
373     //is_123_5 += make_pair<IntervalT, U>(IntervalT::open(v1,v3),u1); //error C2593: 'operator +=' is ambiguous
374     //USASO: unsatisfctory solution 1: explicit IntervalMapT::value_type instead of make_pair
375     is_123_5 += typename IntervalMapT::value_type(icl::interval<T>::open(v1,v3),u1);
376     //USASO: unsatisfctory solution 2: not implementing mapping_type version of o=
377 
378     BOOST_CHECK_EQUAL( cardinality(is_123_5),      icl::infinity<size_T>::value() );
379     BOOST_CHECK_EQUAL( is_123_5.size(),            icl::infinity<size_T>::value() );
380     BOOST_CHECK_EQUAL( icl::length(is_123_5),      d2 );
381 
382 #endif //BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
383 }
384 
385 template
386 <
387 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
388     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
389 #else
390     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
391 #endif
392     class T, class U
393 >
interval_map_isolate_4_bicremental_continuous_types()394 void interval_map_isolate_4_bicremental_continuous_types()
395 {
396 #ifndef BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
397 
398     typedef IntervalMap<T,U> IntervalMapT;
399     typedef typename IntervalMapT::interval_type   IntervalT;
400     typedef typename IntervalMapT::size_type       size_T;
401 
402     T v0 = make<T>(0);
403     T v2 = make<T>(2);
404     T v4 = make<T>(4);
405     U u1 = make<U>(1);
406     IntervalT I0_4I = icl::interval<T>::closed(v0,v4);
407     IntervalT C0_2D = icl::interval<T>::open(v0,v2);
408     IntervalT C2_4D = icl::interval<T>::open(v2,v4);
409     typename IntervalMapT::value_type I0_4I_u1(I0_4I,u1);
410     typename IntervalMapT::value_type C0_2D_u1(C0_2D,u1);
411     typename IntervalMapT::value_type C2_4D_u1(C2_4D,u1);
412     //   {[0               4]}
413     // - {   (0,2)   (2,4)   }
414     // = {[0]     [2]     [4]}
415     IntervalMapT iso_map = IntervalMapT(I0_4I_u1);
416     IntervalMapT gap_set;
417     gap_set.add(C0_2D_u1).add(C2_4D_u1);
418     iso_map -= gap_set;
419 
420     BOOST_CHECK_EQUAL( cardinality(iso_map), static_cast<size_T>(3) );
421     BOOST_CHECK_EQUAL( iso_map.iterative_size(), static_cast<std::size_t>(3) );
422     BOOST_CHECK_EQUAL( iterative_size(iso_map), static_cast<std::size_t>(3) );
423     BOOST_CHECK_EQUAL( iterative_size(iso_map), static_cast<std::size_t>(3) );
424 
425     IntervalMapT iso_map2;
426     iso_map2.add(I0_4I_u1);
427     iso_map2.subtract(C0_2D_u1).subtract(C2_4D_u1);
428 
429     IntervalMapT iso_map3(I0_4I_u1);
430     (iso_map3 -= C0_2D_u1) -= C2_4D_u1;
431 
432     IntervalMapT iso_map4;
433     iso_map4.insert(I0_4I_u1);
434     iso_map4.erase(C0_2D_u1).erase(C2_4D_u1);
435 
436     BOOST_CHECK_EQUAL( iso_map, iso_map2 );
437     BOOST_CHECK_EQUAL( iso_map, iso_map3 );
438     BOOST_CHECK_EQUAL( iso_map, iso_map4 );
439 #endif //BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
440 }
441 
442 
443 template
444 <
445 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
446     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
447 #else
448     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
449 #endif
450     class T, class U
451 >
interval_map_contains_4_bicremental_types()452 void interval_map_contains_4_bicremental_types()
453 {
454     typedef IntervalMap<T,U> IntervalMapT;
455     typedef typename IntervalMapT::set_type IntervalSetT;
456 
457     IntervalMapT itv_map;
458     itv_map.add(K_v(3,1));
459 
460     BOOST_CHECK_EQUAL( icl::contains(itv_map, MK_v(3)), true );
461     BOOST_CHECK_EQUAL( icl::contains(itv_map, K_v(3,1)), true );
462 
463     BOOST_CHECK_EQUAL( icl::contains(IntervalMapT().add(K_v(3,1)), K_v(3,1)), true );
464     BOOST_CHECK_EQUAL( icl::contains(IntervalMapT().add(K_v(3,1)), MK_v(3)), true );
465     BOOST_CHECK_EQUAL( icl::contains(IntervalMapT().insert(K_v(3,1)), K_v(3,1)), true );
466     itv_map.clear();
467     BOOST_CHECK_EQUAL( icl::contains((itv_map += IIv(3,7,1)), IIv(3,7,1)), true );
468     BOOST_CHECK_EQUAL( icl::contains(itv_map, IIv(3,7,2)), false );
469     BOOST_CHECK_EQUAL( icl::contains(itv_map, I_I(3,7)),   true );
470     BOOST_CHECK_EQUAL( icl::contains(itv_map, I_I(4,6)),   true );
471     BOOST_CHECK_EQUAL( icl::contains((itv_map += CIv(7,9,1)),IIv(3,9,1)), true );
472     BOOST_CHECK_EQUAL( icl::contains(itv_map, I_I(4,8)),   true );
473     BOOST_CHECK_EQUAL( icl::contains((itv_map += IIv(11,12,1)), IIv(3,12,1)), false );
474     BOOST_CHECK_EQUAL( icl::contains(itv_map, I_I(4,11)),  false );
475 
476     IntervalMapT itv_map0 = itv_map;
477 
478     itv_map.clear();
479     IntervalMapT itv_map2(IIv(5,8,1));
480     itv_map2.add(K_v(9,1)).add(K_v(11,1));
481     itv_map += itv_map2;
482     BOOST_CHECK_EQUAL( icl::contains(itv_map, itv_map2), true );
483     IntervalSetT itv_set2;
484     icl::domain(itv_set2, itv_map2);
485     BOOST_CHECK_EQUAL( icl::contains(itv_map, itv_set2), true );
486 }
487 
488 template
489 <
490 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
491     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
492 #else
493     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
494 #endif
495     class T, class U
496 >
interval_map_contains_key_objects_4_bicremental_types()497 void interval_map_contains_key_objects_4_bicremental_types()
498 {
499     typedef IntervalMap<T,U> IntervalMapT;
500     typedef typename IntervalMapT::set_type IntervalSetT;
501     IntervalMapT itv_map;
502 
503     itv_map.add(IDv(1,3,1));
504     BOOST_CHECK_EQUAL( icl::contains(itv_map, MK_v(0)), false );
505     BOOST_CHECK_EQUAL( icl::contains(itv_map, MK_v(2)), true );
506     BOOST_CHECK_EQUAL( icl::contains(itv_map, MK_v(3)), false );
507 
508     itv_map.add(IDv(3,6,2));
509     BOOST_CHECK_EQUAL( icl::contains(itv_map, I_I(0,0)), false );
510     contains(itv_map, I_I(2,4));
511     BOOST_CHECK_EQUAL( icl::contains(itv_map, I_I(2,4)), true );
512     BOOST_CHECK_EQUAL( icl::contains(itv_map, I_I(6,6)), false );
513 
514     itv_map.add(IDv(8,9,2));
515 
516     IntervalSetT itv_set;
517     itv_set.add(C_I(1,2)).add(C_D(2,6)).add(I_I(8,8));
518     BOOST_CHECK_EQUAL( icl::contains(itv_map, itv_set), true );
519     itv_set.add(I_I(1,4));
520     BOOST_CHECK_EQUAL( icl::contains(itv_map, itv_set), true );
521     itv_set.add(I_I(1,4));
522     BOOST_CHECK_EQUAL( icl::contains(itv_map, itv_set), true );
523     itv_set.add(I_I(7,7));
524     BOOST_CHECK_EQUAL( icl::contains(itv_map, itv_set), false );
525 
526 }
527 
528 
529 template
530 <
531 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
532     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
533 #else
534     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
535 #endif
536     class T, class U
537 >
interval_map_operators_4_bicremental_types()538 void interval_map_operators_4_bicremental_types()
539 {
540     typedef IntervalMap<T,U> IntervalMapT;
541     T v0 = make<T>(0);
542     T v1 = make<T>(1);
543     T v3 = make<T>(3);
544     T v5 = make<T>(5);
545     T v7 = make<T>(7);
546     T v8 = make<T>(8);
547     U u1 = make<U>(1);
548     //typename IntervalMapT::interval_type I3_5I(icl::interval<T>::closed(v3,v5));
549     typename IntervalMapT::value_type I0_1I_u1(icl::interval<T>::closed(v0,v1),u1);
550     typename IntervalMapT::value_type I3_5I_u1(icl::interval<T>::closed(v3,v5),u1);
551     typename IntervalMapT::value_type I7_8I_u1(icl::interval<T>::closed(v7,v8),u1);
552 
553     IntervalMapT left, left2, right, all, section, complement;
554     left.add(I0_1I_u1).add(I3_5I_u1);
555     (right += I3_5I_u1) += I7_8I_u1;
556     BOOST_CHECK_EQUAL( disjoint(left, right), false );
557     BOOST_CHECK_EQUAL( intersects(left, right), true );
558 
559     (all += left) += right;
560     (section += left) &= right;
561     all -= section;
562     complement += all;
563     //complement.erase(I3_5I);
564     icl::erase(complement, section);
565     BOOST_CHECK_EQUAL( disjoint(section, complement), true );
566     BOOST_CHECK_EQUAL( intersects(section, complement), false );
567 }
568 
569 
570 // Test for nontrivial intersection of interval maps with intervals and values
571 template
572 <
573 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
574     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
575 #else
576     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
577 #endif
578     class T, class U
579 >
interval_map_base_intersect_4_bicremental_types()580 void interval_map_base_intersect_4_bicremental_types()
581 {
582     typedef IntervalMap<T,U> IntervalMapT;
583     typedef typename IntervalMapT::interval_type   IntervalT;
584 
585     T v0 = make<T>(0);
586     T v1 = make<T>(1);
587     T v2 = make<T>(2);
588     T v3 = make<T>(3);
589     T v4 = make<T>(4);
590     T v5 = make<T>(5);
591     T v6 = make<T>(6);
592     T v7 = make<T>(7);
593     T v8 = make<T>(8);
594     T v9 = make<T>(9);
595 
596     U u1 = make<U>(1);
597 
598     IntervalT I0_3D = icl::interval<T>::right_open(v0,v3);
599     IntervalT I1_3D = icl::interval<T>::right_open(v1,v3);
600     IntervalT I1_4D = icl::interval<T>::right_open(v1,v4);
601     IntervalT I1_8D = icl::interval<T>::right_open(v1,v8);
602     IntervalT I2_7D = icl::interval<T>::right_open(v2,v7);
603     IntervalT I2_3D = icl::interval<T>::right_open(v2,v3);
604     IntervalT I5_8D = icl::interval<T>::right_open(v5,v8);
605     IntervalT I6_7D = icl::interval<T>::right_open(v6,v7);
606     IntervalT I6_8D = icl::interval<T>::right_open(v6,v8);
607     IntervalT I6_9D = icl::interval<T>::right_open(v6,v9);
608 
609     typename IntervalMapT::value_type I0_3D_1(I0_3D, u1);
610     typename IntervalMapT::value_type I6_9D_1(I6_9D, u1);
611     typename IntervalMapT::value_type I1_3D_1(I1_3D, u1);
612     typename IntervalMapT::value_type I6_8D_1(I6_8D, u1);
613     typename IntervalMapT::value_type I2_3D_1(I2_3D, u1);
614     typename IntervalMapT::value_type I6_7D_1(I6_7D, u1);
615 
616     //--------------------------------------------------------------------------
617     //map_A        [0       3)       [6    9)
618     //                     1           1
619     //         &=      [1                8)
620     //map_AB   ->      [1   3)       [6  8)
621     //                     1           1
622     //         &=        [2             7)
623     //         ->        [2 3)       [6 7)
624     //                     1           1
625     IntervalMap<T,U> map_A, map_AB, map_ab, map_ab2;
626     interval_set<T>  set_B;
627     map_A.add(I0_3D_1).add(I6_9D_1);
628     map_AB = map_A;
629     map_AB &= I1_8D;
630     map_ab.add(I1_3D_1).add(I6_8D_1);
631 
632     BOOST_CHECK_EQUAL( map_AB, map_ab );
633 
634     map_AB = map_A;
635     (map_AB &= I1_8D) &= I2_7D;
636     map_ab2.add(I2_3D_1).add(I6_7D_1);
637 
638     BOOST_CHECK_EQUAL( map_AB, map_ab2 );
639 
640     //--------------------------------------------------------------------------
641     //map_A        [0       3)       [6    9)
642     //                     1           1
643     //         &=      [1     4)  [5     8)
644     //map_AB   ->      [1   3)       [6  8)
645     //                     1           1
646     //         &=        [2   4)  [5    7)
647     //         ->        [2 3)       [6 7)
648     //                     1           1
649     map_A.clear();
650     map_A.add(I0_3D_1).add(I6_9D_1);
651     set_B.add(I1_4D).add(I5_8D);
652     map_AB = map_A;
653 
654     map_AB &= set_B;
655     map_ab.clear();
656     map_ab.add(I1_3D_1).add(I6_8D_1);
657     BOOST_CHECK_EQUAL( map_AB, map_ab );
658 
659     //--------------------------------------------------------------------------
660     //map_A      [0       3)       [6       9)
661     //                1                1
662     //         &=     1
663     //map_AB ->      [1]
664     //                1
665 
666     map_A.clear();
667     map_A.add(I0_3D_1).add(I6_9D_1);
668     map_AB = map_A;
669     map_AB &= v1;
670     map_ab.clear();
671     map_ab.add(mapping_pair<T,U>(v1,u1));
672 
673     BOOST_CHECK_EQUAL( map_AB, map_ab );
674 }
675 
676 
677 // Test for nontrivial erasure of interval maps with intervals and interval sets
678 template
679 <
680 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
681     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
682 #else
683     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
684 #endif
685     class T, class U
686 >
interval_map_base_erase_4_bicremental_types()687 void interval_map_base_erase_4_bicremental_types()
688 {
689     typedef IntervalMap<T,U> IntervalMapT;
690     typedef typename IntervalMapT::interval_type   IntervalT;
691 
692     T v0 = make<T>(0);
693     T v1 = make<T>(1);
694     T v2 = make<T>(2);
695     T v3 = make<T>(3);
696     T v4 = make<T>(4);
697     T v5 = make<T>(5);
698     T v6 = make<T>(6);
699     T v7 = make<T>(7);
700     T v8 = make<T>(8);
701     T v9 = make<T>(9);
702 
703     U u1 = make<U>(1);
704 
705     IntervalT I0_1D = icl::interval<T>::right_open(v0,v1);
706     IntervalT I0_2D = icl::interval<T>::right_open(v0,v2);
707     IntervalT I0_3D = icl::interval<T>::right_open(v0,v3);
708     IntervalT I1_3D = icl::interval<T>::right_open(v1,v3);
709     //IntervalT I1_4D = icl::interval<T>::right_open(v1,v4);
710     IntervalT I1_8D = icl::interval<T>::right_open(v1,v8);
711     IntervalT I2_4D = icl::interval<T>::right_open(v2,v4);
712     IntervalT I2_7D = icl::interval<T>::right_open(v2,v7);
713     IntervalT I2_3D = icl::interval<T>::right_open(v2,v3);
714     IntervalT I5_7D = icl::interval<T>::right_open(v5,v7);
715     //IntervalT I5_8D = icl::interval<T>::right_open(v5,v8);
716     IntervalT I6_7D = icl::interval<T>::right_open(v6,v7);
717     IntervalT I6_8D = icl::interval<T>::right_open(v6,v8);
718     IntervalT I6_9D = icl::interval<T>::right_open(v6,v9);
719     IntervalT I7_9D = icl::interval<T>::right_open(v7,v9);
720     IntervalT I8_9D = icl::interval<T>::right_open(v8,v9);
721 
722     typename IntervalMapT::value_type I0_1D_1(I0_1D, u1);
723     typename IntervalMapT::value_type I0_3D_1(I0_3D, u1);
724     typename IntervalMapT::value_type I0_2D_1(I0_2D, u1);
725     typename IntervalMapT::value_type I6_9D_1(I6_9D, u1);
726     typename IntervalMapT::value_type I1_3D_1(I1_3D, u1);
727     typename IntervalMapT::value_type I6_8D_1(I6_8D, u1);
728     typename IntervalMapT::value_type I2_3D_1(I2_3D, u1);
729     typename IntervalMapT::value_type I6_7D_1(I6_7D, u1);
730     typename IntervalMapT::value_type I7_9D_1(I7_9D, u1);
731     typename IntervalMapT::value_type I8_9D_1(I8_9D, u1);
732 
733     //--------------------------------------------------------------------------
734     //map_A        [0        3)       [6       9)
735     //                  1                  1
736     //      erase        [2              7)
737     //map_A2   ->  [0   2)                [7   9)
738     //                 1                    1
739     //      erase      [1                   8)
740     //         ->  [0 1)                    [8 9)
741     //               1                       1
742     IntervalMap<T,U> map_A, map_A2, map_A3, map_check2, map_check3;
743     interval_set<T>  set_B;
744     map_A.add(I0_3D_1).add(I6_9D_1);
745     map_A2 = map_A;
746     map_A2.erase(I2_7D);
747     map_check2.add(I0_2D_1).add(I7_9D_1);
748     BOOST_CHECK_EQUAL( map_A2, map_check2 );
749 
750     map_A3 = map_A2;
751     map_A3.erase(I1_8D);
752     map_check3.add(I0_1D_1).add(I8_9D_1);
753     BOOST_CHECK_EQUAL( map_A3, map_check3 );
754 
755 
756     //--------------------------------------------------------------------------
757     //map_A        [0        3)       [6       9)
758     //                  1                  1
759     //      erase        [2              7)
760     //         ->  [0   2)                [7   9)
761     //                 1                    1
762     //      erase      [1                   8)
763     //         ->  [0 1)                    [8 9)
764     //               1                       1
765     map_A3 = map_A;
766     map_A3.erase(I2_7D).erase(I1_8D);
767     BOOST_CHECK_EQUAL( map_A3, map_check3 );
768 
769     //--------------------------------------------------------------------------
770     //map_A        [0        3)       [6       9)
771     //                  1                  1
772     //         -=        [2              7)
773     //         ->  [0   2)                [7   9)
774     //                 1                    1
775     //         -=      [1                   8)
776     //         ->  [0 1)                    [8 9)
777     //               1                       1
778     map_A3 = map_A;
779     (map_A3 -= I2_7D) -= I1_8D;
780     BOOST_CHECK_EQUAL( map_A3, map_check3 );
781 
782     //--------------------------------------------------------------------------
783     //map_A        [0        3)       [6       9)
784     //                  1                  1
785     //      erase        [2    4)   [5   7)
786     //         ->  [0   2)                [7   9)
787     //                 1                    1
788     map_A3 = map_A;
789     set_B.add(I2_4D).add(I5_7D);
790     map_A3 -= set_B;
791     BOOST_CHECK_EQUAL( map_A3, map_check2 );
792 }
793 
794 
795 // Test first_collision
796 template
797 <
798 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
799     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
800 #else
801     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
802 #endif
803     class T, class U
804 >
interval_map_base_is_disjoint_4_bicremental_types()805 void interval_map_base_is_disjoint_4_bicremental_types()
806 {
807     typedef IntervalMap<T,U> IntervalMapT;
808     typedef typename IntervalMapT::interval_type   IntervalT;
809     typedef typename IntervalMap<T,U>::interval_set_type IntervalSetT;
810 
811     T v0 = make<T>(0);
812     T v1 = make<T>(1);
813     T v3 = make<T>(3);
814     T v5 = make<T>(5);
815     T v6 = make<T>(6);
816     T v7 = make<T>(7);
817     T v8 = make<T>(8);
818     T v9 = make<T>(9);
819 
820     U u1 = make<U>(1);
821 
822     IntervalT I0_1D = icl::interval<T>::right_open(v0,v1);
823     IntervalT I1_3D = icl::interval<T>::right_open(v1,v3);
824     IntervalT I3_6D = icl::interval<T>::right_open(v3,v6);
825     IntervalT I5_7D = icl::interval<T>::right_open(v5,v7);
826     IntervalT I6_8D = icl::interval<T>::right_open(v6,v8);
827     IntervalT I8_9D = icl::interval<T>::right_open(v8,v9);
828 
829     typename IntervalMapT::value_type I0_1D_1(I0_1D, u1);
830     typename IntervalMapT::value_type I1_3D_1(I1_3D, u1);
831     typename IntervalMapT::value_type I3_6D_1(I3_6D, u1);
832     typename IntervalMapT::value_type I5_7D_1(I5_7D, u1);
833     typename IntervalMapT::value_type I6_8D_1(I6_8D, u1);
834     typename IntervalMapT::value_type I8_9D_1(I8_9D, u1);
835 
836     //--------------------------------------------------------------------------
837     //map_A          [1      3)       [6       8)
838     //                  1                  1
839     //map_B      [0 1)        [3     6)         [8 9)
840     //             1              1               1
841     IntervalMapT map_A, map_B;
842     IntervalSetT set_A, set_B;
843 
844     map_A.add(I1_3D_1).add(I6_8D_1);
845     map_B.add(I0_1D_1).add(I3_6D_1).add(I8_9D_1);
846     BOOST_CHECK_EQUAL( disjoint(map_A, map_B), true );
847     BOOST_CHECK_EQUAL( disjoint(map_B, map_A), true );
848     BOOST_CHECK_EQUAL( intersects(map_A, map_B), false );
849     BOOST_CHECK_EQUAL( intersects(map_B, map_A), false );
850 
851     icl::domain(set_A, map_A);
852     icl::domain(set_B, map_B);
853     BOOST_CHECK_EQUAL( disjoint(map_A, set_B), true );
854     BOOST_CHECK_EQUAL( disjoint(set_B, map_A), true );
855     BOOST_CHECK_EQUAL( disjoint(set_A, map_B), true );
856     BOOST_CHECK_EQUAL( disjoint(map_B, set_A), true );
857     BOOST_CHECK_EQUAL( intersects(map_A, set_B), false );
858     BOOST_CHECK_EQUAL( intersects(set_B, map_A), false );
859     BOOST_CHECK_EQUAL( intersects(set_A, map_B), false );
860     BOOST_CHECK_EQUAL( intersects(map_B, set_A), false );
861 
862     map_A += I5_7D_1;
863 
864     BOOST_CHECK_EQUAL( disjoint(map_A, map_B), false );
865     BOOST_CHECK_EQUAL( disjoint(map_B, map_A), false );
866     BOOST_CHECK_EQUAL( intersects(map_A, map_B),  true );
867     BOOST_CHECK_EQUAL( intersects(map_B, map_A),  true );
868 
869     icl::domain(set_A, map_A);
870     icl::domain(set_B, map_B);
871     BOOST_CHECK_EQUAL( disjoint(map_A, set_B), false );
872     BOOST_CHECK_EQUAL( disjoint(set_B, map_A), false );
873     BOOST_CHECK_EQUAL( disjoint(set_A, map_B), false );
874     BOOST_CHECK_EQUAL( disjoint(map_B, set_A), false );
875     BOOST_CHECK_EQUAL( intersects(map_A, set_B), true );
876     BOOST_CHECK_EQUAL( intersects(set_B, map_A), true );
877     BOOST_CHECK_EQUAL( intersects(set_A, map_B), true );
878     BOOST_CHECK_EQUAL( intersects(map_B, set_A), true );
879 }
880 
881 template
882 <
883 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
884     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
885 #else
886     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
887 #endif
888     class T, class U
889 >
interval_map_flip_4_bicremental_types()890 void interval_map_flip_4_bicremental_types()
891 {
892     typedef IntervalMap<T,U> IntervalMapT;
893     typedef IntervalMapT IMap;
894 
895     IntervalMapT set_a;
896     //[0     2)
897     //    1
898     //    [1     3)
899     //        1
900     //[0 1)   [2 3) : {[0 2)->1} ^= ([2 3)->1)
901     //  1       1
902     //BOOST_CHECK_EQUAL(IMap(IDv(0,2,1)) ^= (IDv(1,3,1)), IMap(IDv(0,1,1)) + IDv(2,3,1));
903     set_a = IMap(IDv(0,2,1));
904     IntervalMapT set_b = set_a;
905     BOOST_CHECK_EQUAL(set_a ^= IDv(1,3,1), IMap(IDv(0,1,1)) + IDv(2,3,1));
906 }
907 
908 template
909 <
910 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
911     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
912 #else
913     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
914 #endif
915     class T, class U
916 >
interval_map_infix_plus_overload_4_bicremental_types()917 void interval_map_infix_plus_overload_4_bicremental_types()
918 {
919     typedef IntervalMap<T,U> IntervalMapT;
920     typedef typename IntervalMapT::interval_type   IntervalT;
921     typename IntervalMapT::interval_mapping_type val_pair1 = IDv(6,9,1);
922     std::pair<const IntervalT, U> val_pair2 = IDv(3,5,3);
923     mapping_pair<T,U> map_pair = K_v(4,3);
924 
925     IntervalMapT map_a, map_b;
926     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
927     map_b.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
928 
929     BOOST_CHECK_EQUAL(map_a + map_b, map_b + map_a);
930     //This checks all cases of is_interval_map_derivative<T>
931     BOOST_CHECK_EQUAL(map_a + val_pair1, val_pair1 + map_a);
932     BOOST_CHECK_EQUAL(map_b + val_pair2, val_pair2 + map_b);
933     BOOST_CHECK_EQUAL(map_b + map_pair, map_pair + map_b);
934 }
935 
936 template
937 <
938 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
939     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
940 #else
941     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
942 #endif
943     class T, class U
944 >
interval_map_infix_pipe_overload_4_bicremental_types()945 void interval_map_infix_pipe_overload_4_bicremental_types()
946 {
947     typedef IntervalMap<T,U> IntervalMapT;
948     typedef typename IntervalMapT::interval_type   IntervalT;
949     typename IntervalMapT::interval_mapping_type val_pair1 = IDv(6,9,1);
950     std::pair<const IntervalT, U> val_pair2 = IDv(3,5,3);
951     mapping_pair<T,U> map_pair = K_v(4,3);
952 
953     IntervalMapT map_a, map_b;
954     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
955     map_b.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
956 
957     BOOST_CHECK_EQUAL(map_a | map_b, map_b | map_a);
958     //This checks all cases of is_interval_map_derivative<T>
959     BOOST_CHECK_EQUAL(map_a | val_pair1, val_pair1 | map_a);
960     BOOST_CHECK_EQUAL(map_b | val_pair2, val_pair2 | map_b);
961     BOOST_CHECK_EQUAL(map_b | map_pair, map_pair | map_b);
962 }
963 
964 
965 
966 template
967 <
968 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
969     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
970 #else
971     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
972 #endif
973     class T, class U
974 >
interval_map_infix_minus_overload_4_bicremental_types()975 void interval_map_infix_minus_overload_4_bicremental_types()
976 {
977     typedef IntervalMap<T,U> IntervalMapT;
978     typedef typename IntervalMapT::interval_type   IntervalT;
979 
980     typename IntervalMapT::interval_mapping_type val_pair1 = IDv(6,9,1);
981     std::pair<const IntervalT, U> val_pair2 = IDv(3,5,3);
982     mapping_pair<T,U> map_pair = K_v(4,3);
983 
984     IntervalT itv = C_D(4,11);
985     typename IntervalMapT::interval_mapping_type itv_v = CDv(4,11,3);
986 
987     IntervalMapT map_a, map_b, map_c;
988     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
989     map_b.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
990     map_c = map_a;
991 
992     interval_set<T>          join_set_a;
993     separate_interval_set<T> sep_set_a;
994     split_interval_set<T>    split_set_a;
995     join_set_a .add(I_D(0,4)).add(I_I(4,6)).add(I_D(5,9));
996     sep_set_a  .add(I_D(0,4)).add(I_I(4,6)).add(I_D(5,11));
997     split_set_a.add(I_I(0,0)).add(I_D(8,7)).add(I_I(6,11));
998 
999     //Happy day overloading
1000     BOOST_CHECK_EQUAL(map_a - map_b, (map_c = map_a) -= map_b);
1001     BOOST_CHECK_EQUAL(map_a - map_b, map_c);
1002 
1003     //This checks all cases of is_interval_map_derivative<T>
1004     BOOST_CHECK_EQUAL((map_a - val_pair1) + val_pair1, (map_a + val_pair1) - val_pair1);
1005     BOOST_CHECK_EQUAL((map_b - val_pair2) + val_pair2, (map_b + val_pair2) - val_pair2);
1006     BOOST_CHECK_EQUAL((map_b - map_pair)  + map_pair,  (map_b + map_pair)  - map_pair);
1007 
1008     //This checks all cases of is_interval_set_derivative<T>
1009     BOOST_CHECK_EQUAL(map_a - itv,     (map_a + itv_v) - itv);
1010     BOOST_CHECK_EQUAL(map_b - MK_v(8), (IIv(8,8,3) + map_b) - MK_v(8));
1011 
1012     //This checks all cases of is_interval_set_companion<T>
1013     BOOST_CHECK_EQUAL(map_a - split_set_a, ((split_set_a & map_a) + map_a) - split_set_a);
1014     BOOST_CHECK_EQUAL(map_a - sep_set_a,   ((sep_set_a   & map_a) + map_a) - sep_set_a);
1015     BOOST_CHECK_EQUAL(map_a - join_set_a,  ((join_set_a  & map_a) + map_a) - join_set_a);
1016 }
1017 
1018 
1019 template
1020 <
1021 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1022     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
1023 #else
1024     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
1025 #endif
1026     class T, class U
1027 >
interval_map_infix_et_overload_4_bicremental_types()1028 void interval_map_infix_et_overload_4_bicremental_types()
1029 {
1030     typedef IntervalMap<T,U> IntervalMapT;
1031     typedef typename IntervalMapT::interval_type   IntervalT;
1032 
1033     typename IntervalMapT::interval_mapping_type val_pair1 = IDv(6,9,1);
1034     std::pair<const IntervalT, U> val_pair2 = IDv(3,5,3);
1035     mapping_pair<T,U> map_pair = K_v(4,3);
1036 
1037     IntervalT itv = C_D(4,11);
1038 
1039     IntervalMapT map_a, map_b;
1040     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
1041     map_b.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
1042 
1043     interval_set<T>          join_set_a;
1044     separate_interval_set<T> sep_set_a;
1045     split_interval_set<T>    split_set_a;
1046     join_set_a .add(I_D(0,4)).add(I_I(4,6)).add(I_D(5,9));
1047     sep_set_a  .add(I_D(0,4)).add(I_I(4,6)).add(I_D(5,11));
1048     split_set_a.add(I_I(0,0)).add(I_D(8,7)).add(I_I(6,11));
1049 
1050     //Happy day overloading
1051     BOOST_CHECK_EQUAL(map_a & map_b, map_b & map_a);
1052 
1053     //This checks all cases of is_interval_map_derivative<T>
1054     BOOST_CHECK_EQUAL(map_a & val_pair1, val_pair1 & map_a);
1055     BOOST_CHECK_EQUAL(map_b & val_pair2, val_pair2 & map_b);
1056     BOOST_CHECK_EQUAL(map_b & map_pair, map_pair & map_b);
1057 
1058     //This checks all cases of is_interval_set_derivative<T>
1059     BOOST_CHECK_EQUAL(map_a & itv, itv & map_a);
1060     BOOST_CHECK_EQUAL(map_b & MK_v(8), MK_v(8) & map_b);
1061 
1062     //This checks all cases of is_interval_set_companion<T>
1063     BOOST_CHECK_EQUAL(map_a & split_set_a, split_set_a & map_a);
1064     BOOST_CHECK_EQUAL(map_a & sep_set_a,   sep_set_a   & map_a);
1065     BOOST_CHECK_EQUAL(map_a & join_set_a,  join_set_a  & map_a);
1066 }
1067 
1068 
1069 template
1070 <
1071 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1072     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
1073 #else
1074     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
1075 #endif
1076     class T, class U
1077 >
interval_map_infix_caret_overload_4_bicremental_types()1078 void interval_map_infix_caret_overload_4_bicremental_types()
1079 {
1080     typedef IntervalMap<T,U> IntervalMapT;
1081     typedef typename IntervalMapT::interval_type   IntervalT;
1082 
1083     typename IntervalMapT::interval_mapping_type val_pair1 = IDv(6,9,1);
1084     std::pair<const IntervalT, U> val_pair2 = IDv(3,5,3);
1085     mapping_pair<T,U> map_pair = K_v(4,3);
1086 
1087     //IntervalT itv = C_D(4,11);
1088 
1089     IntervalMapT map_a, map_b;
1090     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
1091     map_b.add(IDv(0,9,2)).add(IIv(3,6,1)).add(IDv(5,7,1));
1092 
1093     interval_set<T>          join_set_a;
1094     separate_interval_set<T> sep_set_a;
1095     split_interval_set<T>    split_set_a;
1096     join_set_a .add(I_D(0,4)).add(I_I(4,6)).add(I_D(5,9));
1097     sep_set_a  .add(I_D(0,4)).add(I_I(4,6)).add(I_D(5,11));
1098     split_set_a.add(I_I(0,0)).add(I_D(8,7)).add(I_I(6,11));
1099 
1100     //Happy day overloading
1101     BOOST_CHECK_EQUAL(map_a ^ map_b, map_b ^ map_a);
1102 
1103     //This checks all cases of is_interval_map_derivative<T>
1104     BOOST_CHECK_EQUAL(map_a ^ val_pair1, val_pair1 ^ map_a);
1105     BOOST_CHECK_EQUAL(map_b ^ val_pair2, val_pair2 ^ map_b);
1106     BOOST_CHECK_EQUAL(map_b ^ map_pair,  map_pair ^ map_b);
1107 }
1108 
1109 template
1110 <
1111 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1112     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
1113 #else
1114     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
1115 #endif
1116     class T, class U
1117 >
interval_map_find_4_bicremental_types()1118 void interval_map_find_4_bicremental_types()
1119 {
1120     typedef IntervalMap<T,U> IntervalMapT;
1121     typedef typename IntervalMapT::const_iterator c_iterator;
1122 
1123     IntervalMapT map_a;
1124     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
1125     // {(1  3)    [6  8)[8 9)[9  11)
1126     //     1         3    4     3
1127     //          5? 6?
1128     c_iterator found1 = map_a.find(MK_v(6));
1129     c_iterator found2 = icl::find(map_a, MK_v(6));
1130 
1131     BOOST_CHECK      ( found1 == found2 );
1132     BOOST_CHECK_EQUAL( found1->second, found2->second );
1133     BOOST_CHECK_EQUAL( found1->second, MK_u(3) );
1134     BOOST_CHECK_EQUAL( map_a(MK_v(6)), MK_u(3) );
1135 
1136     found1 = map_a.find(MK_v(5));
1137 
1138     BOOST_CHECK_EQUAL( found1 == map_a.end(), true );
1139     BOOST_CHECK_EQUAL( map_a(MK_v(5)), MK_u(0) );
1140     BOOST_CHECK_EQUAL( map_a(MK_v(8)), MK_u(4) );
1141 
1142     /*JODO fix err for boost::chrono instantiation
1143     T k_2  = MK_v( 2);
1144     T k_11 = MK_v(11);
1145     //LAW map c; key k: k in dom(c) => contains(c, (k, find(c, k)->second))
1146     BOOST_CHECK( icl::contains(map_a, K_v(k_2,  icl::find(map_a, k_2)->second)) );
1147     BOOST_CHECK( icl::contains(map_a, K_v(k_11, map_a.find(k_11)->second)) );
1148     */
1149     BOOST_CHECK(  icl::contains(map_a, MK_v(2)) );
1150     BOOST_CHECK(  icl::contains(map_a, MK_v(10)) );
1151     BOOST_CHECK( !icl::contains(map_a, MK_v(1)) );
1152     BOOST_CHECK( !icl::contains(map_a, MK_v(3)) );
1153     BOOST_CHECK( !icl::contains(map_a, MK_v(12)) );
1154 
1155     BOOST_CHECK(  icl::intersects(map_a, MK_v(2)) );
1156     BOOST_CHECK(  icl::intersects(map_a, MK_v(10)) );
1157     BOOST_CHECK( !icl::intersects(map_a, MK_v(1)) );
1158     BOOST_CHECK( !icl::intersects(map_a, MK_v(3)) );
1159     BOOST_CHECK( !icl::intersects(map_a, MK_v(12)) );
1160 }
1161 
1162 
1163 template
1164 <
1165 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1166     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
1167 #else
1168     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
1169 #endif
1170     class T, class U
1171 >
interval_map_find_4_numeric_continuous_types()1172 void interval_map_find_4_numeric_continuous_types()
1173 {
1174 #ifndef BOOST_ICL_TEST_CHRONO
1175     typedef IntervalMap<T,U> IntervalMapT;
1176     typedef typename IntervalMapT::interval_type  IntervalT;
1177     typedef typename IntervalMapT::const_iterator c_iterator;
1178 
1179     T q_1_2 = MK_v(1) / MK_v(2);//JODO Doesn't work with chrono
1180     T q_3_2 = MK_v(3) / MK_v(2);
1181     T q_1_3 = MK_v(1) / MK_v(3);
1182     T q_2_3 = MK_v(2) / MK_v(3);
1183     T q_4_3 = MK_v(4) / MK_v(3);
1184     T q_5_3 = MK_v(5) / MK_v(3);
1185 
1186     IntervalMapT map_a;
1187     map_a.add(MK_seg(IntervalT(q_1_3, q_2_3), 1)).add(MK_seg(IntervalT(q_4_3, q_5_3), 2));
1188     // {[1/3   2/3)    [4/3   5/3)}
1189     //       1              2
1190 
1191     c_iterator found1 = map_a.find(q_1_2);
1192     c_iterator found2 = icl::find(map_a, q_1_2);
1193     BOOST_CHECK      ( found1 == found2 );
1194     BOOST_CHECK_EQUAL( found1->second, found2->second );
1195     BOOST_CHECK_EQUAL( found1->second, MK_u(1) );
1196 
1197     found1 = map_a.find(q_3_2);
1198     found2 = icl::find(map_a, q_3_2);
1199     BOOST_CHECK      ( found1 == found2 );
1200     BOOST_CHECK_EQUAL( found1->second, found2->second );
1201     BOOST_CHECK_EQUAL( found1->second, MK_u(2) );
1202 
1203     if( mpl::or_<mpl::not_<is_static_left_open<IntervalT> >, boost::is_signed<T> >::value )
1204     {
1205         found1 = map_a.find(MK_v(0));
1206         found2 = icl::find(map_a, MK_v(0));
1207         BOOST_CHECK      ( found1 == found2 );
1208         BOOST_CHECK      ( found1 == map_a.end() );
1209     }
1210 
1211     found1 = map_a.find(MK_v(1));
1212     found2 = icl::find(map_a, MK_v(1));
1213     BOOST_CHECK      ( found1 == found2 );
1214     BOOST_CHECK      ( found1 == map_a.end() );
1215 
1216     if( mpl::or_<mpl::not_<is_static_left_open<IntervalT> >, boost::is_signed<T> >::value )
1217     {
1218         BOOST_CHECK( !icl::contains(map_a, MK_v(0)) );
1219     }
1220     BOOST_CHECK(  icl::contains(map_a, q_1_2) );
1221     BOOST_CHECK( !icl::contains(map_a, MK_v(1)) );
1222     BOOST_CHECK(  icl::contains(map_a, q_3_2) );
1223     BOOST_CHECK( !icl::contains(map_a, MK_v(2)) );
1224 #endif
1225 }
1226 
1227 
1228 template
1229 <
1230 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1231     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
1232 #else
1233     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
1234 #endif
1235     class T, class U
1236 >
interval_map_range_4_bicremental_types()1237 void interval_map_range_4_bicremental_types()
1238 {
1239     typedef IntervalMap<T,U> IntervalMapT;
1240     typedef typename IntervalMapT::interval_type  IntervalT;
1241     typedef typename IntervalMapT::const_iterator c_iterator;
1242 
1243     IntervalMapT map_a;
1244     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
1245     // {(1  3)    [6  8)[8 9)[9  11)
1246     //     1         3    4     3
1247     //    [2        7) := itv
1248 
1249     IntervalT itv = I_D(2, 7);
1250     c_iterator lwb1 = icl::find(map_a, itv);
1251     c_iterator lwb2 = map_a.lower_bound(itv);
1252 
1253     BOOST_CHECK      ( lwb1 == lwb2 );
1254     BOOST_CHECK_EQUAL( lwb1->second, lwb2->second );
1255     BOOST_CHECK_EQUAL( lwb1->second, MK_u(1) );
1256 
1257     c_iterator upb1 = map_a.upper_bound(itv);
1258     BOOST_CHECK_EQUAL( upb1->second, MK_u(4) );
1259 
1260     std::pair<c_iterator,c_iterator> exterior =  map_a.equal_range(itv);
1261     BOOST_CHECK      ( lwb1 == exterior.first );
1262     BOOST_CHECK      ( upb1 == exterior.second );
1263 }
1264 
1265 
1266 template
1267 <
1268 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1269     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
1270 #else
1271     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
1272 #endif
1273     class T, class U
1274 >
interval_map_set_4_bicremental_types()1275 void interval_map_set_4_bicremental_types()
1276 {
1277     typedef IntervalMap<T,U> IntervalMapT;
1278 
1279     IntervalMapT map_a;
1280     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
1281 
1282     BOOST_CHECK_EQUAL( icl::contains(map_a.set(CDv(2,10,4)), CDv(2,10,4)), true );
1283     BOOST_CHECK_EQUAL( icl::contains(map_a.set(K_v(4,5)), K_v(4,5)), true );
1284     BOOST_CHECK_EQUAL( icl::contains(map_a.set(K_v(4,5)).set(CDv(3,5,6)), CDv(3,5,6)), true );
1285 }
1286 
1287 
1288 template
1289 <
1290     class T, class U, class Trt,
1291 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1292     ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
1293 #else
1294     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
1295 #endif
1296 >
interval_map_inclusion_compare_4_bicremental_types()1297 void interval_map_inclusion_compare_4_bicremental_types()
1298 {
1299     typedef IntervalMap<T,U,Trt> IntervalMapT;
1300     typedef typename IntervalMap<T,U,Trt>::set_type IntervalSetT;
1301 
1302     IntervalMapT itv_map_sub_a, itv_map_a, itv_map_a2, itv_map_super_a,
1303                  itv_map_b, itv_map_c;
1304     itv_map_sub_a.add(IDv(2,4,1)).add(IIv(6,7,3));
1305     itv_map_a = itv_map_sub_a;
1306     itv_map_a.add(IIv(9,9,1));
1307     itv_map_a2 = itv_map_a;
1308     itv_map_c = itv_map_sub_a;
1309     itv_map_c.erase(MK_v(7)).add(IIv(11,11,2));
1310     itv_map_b = itv_map_a;
1311     itv_map_b.set(IIv(6,7,2));
1312 
1313 
1314     BOOST_CHECK_EQUAL( inclusion_compare(IntervalMapT(), IntervalMapT()), inclusion::equal );
1315     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, itv_map_a), inclusion::equal );
1316     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, itv_map_a2), inclusion::equal );
1317 
1318     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, IntervalMapT()), inclusion::superset );
1319     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, itv_map_sub_a), inclusion::superset );
1320     BOOST_CHECK_EQUAL( inclusion_compare(IntervalMapT(), itv_map_a), inclusion::subset );
1321     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_sub_a, itv_map_a), inclusion::subset );
1322 
1323     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, itv_map_b), inclusion::unrelated );
1324     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, itv_map_c), inclusion::unrelated );
1325 
1326     IntervalSetT set_sub_a, set_a, set_a2, set_b, set_c;
1327     icl::domain(set_a, itv_map_a);
1328     icl::domain(set_a2, itv_map_a2);
1329     icl::domain(set_sub_a, itv_map_sub_a);
1330 
1331     BOOST_CHECK_EQUAL( inclusion_compare(IntervalMapT(), IntervalSetT()), inclusion::equal );
1332     BOOST_CHECK_EQUAL( inclusion_compare(IntervalSetT(), IntervalMapT()), inclusion::equal );
1333     BOOST_CHECK_EQUAL( inclusion_compare(IntervalSetT(), IntervalSetT()), inclusion::equal );
1334 
1335     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, set_a), inclusion::equal );
1336     BOOST_CHECK_EQUAL( inclusion_compare(set_a, itv_map_a), inclusion::equal );
1337     BOOST_CHECK_EQUAL( inclusion_compare(set_a, set_a2), inclusion::equal );
1338 
1339     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, IntervalSetT()), inclusion::superset );
1340     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_a, set_sub_a), inclusion::superset );
1341 
1342     BOOST_CHECK_EQUAL( inclusion_compare(IntervalSetT(), itv_map_a), inclusion::subset );
1343     BOOST_CHECK_EQUAL( inclusion_compare(set_sub_a, itv_map_a), inclusion::subset );
1344 
1345     BOOST_CHECK_EQUAL( inclusion_compare(set_a, IntervalSetT()), inclusion::superset );
1346     BOOST_CHECK_EQUAL( inclusion_compare(set_a, set_sub_a), inclusion::superset );
1347 
1348     BOOST_CHECK_EQUAL( inclusion_compare(IntervalSetT(), set_a), inclusion::subset );
1349     BOOST_CHECK_EQUAL( inclusion_compare(set_sub_a, set_a), inclusion::subset );
1350 
1351     BOOST_CHECK_EQUAL( inclusion_compare(set_a, itv_map_c), inclusion::unrelated );
1352     BOOST_CHECK_EQUAL( inclusion_compare(itv_map_c, set_a), inclusion::unrelated );
1353 
1354 }
1355 
1356 template
1357 <
1358     class T, class U, class Trt,
1359 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1360     ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
1361 #else
1362     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
1363 #endif
1364 >
interval_map_std_copy_via_inserter_4_bicremental_types()1365 void interval_map_std_copy_via_inserter_4_bicremental_types()
1366 {
1367     typedef IntervalMap<T,U,Trt> IntervalMapT; //Nedded for the test value generator
1368     typedef typename IntervalMapT::interval_type   IntervalT;
1369 
1370     // Check equality of copying using handcoded loop or std::copy via inserter.
1371     typedef std::pair<IntervalT, U> SegmentT;
1372     std::vector<SegmentT> seg_vec_a;
1373     IntervalMapT std_copied_map;
1374 
1375     // For an empty sequence
1376     test_interval_map_copy_via_inserter(seg_vec_a, std_copied_map);
1377 
1378     // For an singleton sequence
1379     seg_vec_a.push_back(IDv(0,1,1));
1380     test_interval_map_copy_via_inserter(seg_vec_a, std_copied_map);
1381 
1382     // Two separate segments
1383     seg_vec_a.push_back(IDv(3,5,1));
1384     test_interval_map_copy_via_inserter(seg_vec_a, std_copied_map);
1385 
1386     // Touching case
1387     seg_vec_a.push_back(IDv(5,7,1));
1388     test_interval_map_copy_via_inserter(seg_vec_a, std_copied_map);
1389 
1390     // Overlapping case
1391     seg_vec_a.push_back(IDv(6,9,1));
1392     test_interval_map_copy_via_inserter(seg_vec_a, std_copied_map);
1393 
1394 }
1395 
1396 
1397 template
1398 <
1399     class T, class U, class Trt,
1400 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1401     ICL_IntervalMap_TEMPLATE(T,U,Traits,Trt) IntervalMap
1402 #else
1403     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,Trt) IntervalMap
1404 #endif
1405 >
interval_map_element_iter_4_discrete_types()1406 void interval_map_element_iter_4_discrete_types()
1407 {
1408     typedef IntervalMap<T,U,Trt> IntervalMapT;
1409     typedef std::vector<std::pair<T,U> > VectorT;
1410 
1411     IntervalMapT map_a;
1412     map_a.insert(IIv(1,3,1)).insert(IIv(6,7,2));
1413 
1414     typename IntervalMapT::atomized_type ato_map_a;
1415     //ReptatorT el_it = elements_begin(map_a);
1416 
1417     VectorT vec(5), cev(5);
1418     vec[0]=sK_v(1,1);vec[1]=sK_v(2,1);vec[2]=sK_v(3,1);vec[3]=sK_v(6,2);vec[4]=sK_v(7,2);
1419     cev[0]=sK_v(7,2);cev[1]=sK_v(6,2);cev[2]=sK_v(3,1);cev[3]=sK_v(2,1);cev[4]=sK_v(1,1);
1420 
1421     VectorT dest;
1422     std::copy(elements_begin(map_a), elements_end(map_a), std::back_inserter(dest));
1423     BOOST_CHECK_EQUAL( vec == dest, true );
1424 
1425     dest.clear();
1426     std::copy(elements_rbegin(map_a), elements_rend(map_a), std::back_inserter(dest));
1427     BOOST_CHECK_EQUAL( cev == dest, true );
1428 
1429     dest.clear();
1430     std::reverse_copy(elements_rbegin(map_a), elements_rend(map_a), std::back_inserter(dest));
1431     BOOST_CHECK_EQUAL( vec == dest, true );
1432 
1433     dest.clear();
1434     std::reverse_copy(elements_begin(map_a), elements_end(map_a), std::back_inserter(dest));
1435     BOOST_CHECK_EQUAL( cev == dest, true );
1436 
1437 }
1438 
1439 
1440 template
1441 <
1442 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1443     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
1444 #else
1445     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
1446 #endif
1447     class T, class U
1448 >
interval_map_intersects_4_bicremental_types()1449 void interval_map_intersects_4_bicremental_types()
1450 {
1451     // Test of intersects and disjoint for domain_type and interval_type.
1452     typedef IntervalMap<T,U> IntervalMapT;
1453 
1454     IntervalMapT map_a;
1455     map_a.add(CDv(1,3,1)).add(IDv(8,9,1)).add(IIv(6,11,3));
1456 
1457     BOOST_CHECK( icl::is_interval_container<IntervalMapT>::value );
1458     BOOST_CHECK( icl::has_domain_type<IntervalMapT>::value );
1459     BOOST_CHECK( (boost::is_same<T, typename domain_type_of<IntervalMapT>::type>::value) );
1460 
1461     BOOST_CHECK( icl::intersects(map_a,  MK_v(2) ) );
1462     BOOST_CHECK( icl::intersects(map_a,  MK_v(11)) );
1463     BOOST_CHECK( icl::disjoint(map_a, MK_v(1) ) );
1464     BOOST_CHECK( icl::disjoint(map_a, MK_v(12)) );
1465 
1466     BOOST_CHECK( icl::intersects(map_a, I_D(2,3)) );
1467     BOOST_CHECK( icl::intersects(map_a, I_D(6,8)) );
1468     BOOST_CHECK( icl::disjoint(map_a,   I_D(3,5)) );
1469     BOOST_CHECK( icl::disjoint(map_a,  I_D(12,14)) );
1470 
1471     //-------------------------------------+
1472     //   (1   3)      [6   8)[8 9)[9    11]
1473     //      1            3     4      3
1474     mapping_pair<T,U> map_pair_2_1  = K_v(2,1);
1475     BOOST_CHECK( icl::intersects(map_a,  map_pair_2_1 ) );
1476     BOOST_CHECK( icl::intersects(map_a,  K_v(6,3) ) );
1477     BOOST_CHECK( icl::intersects(map_a,  IDv(6,8,3) ) );
1478     BOOST_CHECK( icl::intersects(map_a,  CIv(8,11,3) ) );
1479     BOOST_CHECK( icl::intersects(map_a,  IIv(6,11,3) ) );
1480     BOOST_CHECK( icl::intersects(map_a,  IIv(6,11,5) ) );
1481     BOOST_CHECK(!icl::intersects(map_a,  IDv(4,6,5) ) );
1482 
1483     BOOST_CHECK( icl::disjoint(map_a,  IDv(4,6,5) ) );
1484     BOOST_CHECK(!icl::disjoint(map_a,  IDv(0,12,1) ) );
1485 }
1486 
1487 
1488 template
1489 <
1490 #if (defined(__GNUC__) && (__GNUC__ < 4)) //MEMO Can be simplified, if gcc-3.4 is obsolete
1491     ICL_IntervalMap_TEMPLATE(T,U,Traits,partial_absorber) IntervalMap,
1492 #else
1493     ICL_IntervalMap_TEMPLATE(_T,_U,Traits,partial_absorber) IntervalMap,
1494 #endif
1495     class T, class U
1496 >
interval_map_move_4_discrete_types()1497 void interval_map_move_4_discrete_types()
1498 {
1499 #   ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
1500     typedef IntervalMap<T,U> IntervalMapT;
1501 
1502     IntervalMapT map_A(boost::move(IntervalMapT(IDv(0,4,2))));
1503     IntervalMapT map_B(boost::move(IntervalMapT(IDv(0,2,1)).add(IDv(2,4,1)).add(IDv(0,4,1))));
1504 
1505     BOOST_CHECK( icl::is_element_equal(map_A, map_B) );
1506     BOOST_CHECK_EQUAL( map_A, join(map_B) );
1507 
1508     map_A = boost::move(IntervalMapT(IIv(1,4,2)));
1509     map_B = boost::move(IntervalMapT(CIv(0,2,1)).insert(IDv(3,5,1)).add(CDv(0,5,1)));
1510 
1511     BOOST_CHECK( icl::is_element_equal(map_A, map_B) );
1512     BOOST_CHECK_EQUAL( map_A, join(map_B) );
1513 
1514 #   endif // BOOST_NO_CXX11_RVALUE_REFERENCES
1515 }
1516 
1517 
1518 #endif // LIBS_ICL_TEST_TEST_INTERVAL_MAP_SHARED_HPP_JOFA_081005
1519