|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r69480 - in trunk: boost/icl boost/icl/concept libs/icl/test libs/icl/test/fast_stat_interval_map_ libs/icl/test/fastest_icl_interval_
From: afojgo_at_[hidden]
Date: 2011-03-02 09:04:11
Author: jofaber
Date: 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
New Revision: 69480
URL: http://svn.boost.org/trac/boost/changeset/69480
Log:
Renamed unit_closure to detail::unit_trail. It shall not yet go to the public interface. Added tests for fixes around ticket #5207.
Text files modified:
trunk/boost/icl/concept/interval.hpp | 20 ++++++++++++--------
trunk/boost/icl/concept/interval_associator_base.hpp | 36 +++++++++++++++++++++++++++++-------
trunk/boost/icl/interval_base_map.hpp | 1 -
trunk/libs/icl/test/Jamfile.v2 | 8 +++++---
trunk/libs/icl/test/fast_stat_interval_map_/fast_stat_interval_map.cpp | 4 +++-
trunk/libs/icl/test/fast_stat_interval_map_cases.hpp | 31 ++++++++-----------------------
trunk/libs/icl/test/fastest_icl_interval_/fastest_icl_interval.cpp | 2 --
trunk/libs/icl/test/test_icl_interval.hpp | 6 +++---
trunk/libs/icl/test/test_interval_map_shared.hpp | 33 +++++++++++++++++++++++----------
9 files changed, 83 insertions(+), 58 deletions(-)
Modified: trunk/boost/icl/concept/interval.hpp
==============================================================================
--- trunk/boost/icl/concept/interval.hpp (original)
+++ trunk/boost/icl/concept/interval.hpp 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -119,12 +119,15 @@
return dynamic_interval_traits<Type>::construct(value, value, interval_bounds::closed());
}
+namespace detail
+{
+
//==============================================================================
-//= Construct<Interval> unit_closure == generalized singleton
+//= Construct<Interval> unit_trail == generalized singleton
// The smallest interval on an incrementable (and decrementable) type that can
// be constructed using ++ and -- and such that it contains a given value.
-// If 'Type' is discrete, 'unit_closure' and 'singleton' are identical. So we
-// can view 'unit_closure' as a generalized singleton for static intervals of
+// If 'Type' is discrete, 'unit_trail' and 'singleton' are identical. So we
+// can view 'unit_trail' as a generalized singleton for static intervals of
// continuous types.
//==============================================================================
template<class Type>
@@ -134,7 +137,7 @@
, boost::detail::is_incrementable<typename interval_traits<Type>::domain_type> >
, Type
>::type
-unit_closure(const typename interval_traits<Type>::domain_type& value)
+unit_trail(const typename interval_traits<Type>::domain_type& value)
{
return interval_traits<Type>::construct(value, icl::succ(value));
}
@@ -146,7 +149,7 @@
, boost::detail::is_incrementable<typename interval_traits<Type>::domain_type> >
, Type
>::type
-unit_closure(const typename interval_traits<Type>::domain_type& value)
+unit_trail(const typename interval_traits<Type>::domain_type& value)
{
typedef typename interval_traits<Type>::domain_type domain_type;
BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(value) ));
@@ -161,7 +164,7 @@
, is_discrete<typename interval_traits<Type>::domain_type> >
, Type
>::type
-unit_closure(const typename interval_traits<Type>::domain_type& value)
+unit_trail(const typename interval_traits<Type>::domain_type& value)
{
typedef typename interval_traits<Type>::domain_type domain_type;
BOOST_ASSERT((numeric_minimum<domain_type, is_numeric<domain_type>::value >::is_less_than(value)));
@@ -176,7 +179,7 @@
, is_discrete<typename interval_traits<Type>::domain_type> >
, Type
>::type
-unit_closure(const typename interval_traits<Type>::domain_type& value)
+unit_trail(const typename interval_traits<Type>::domain_type& value)
{
return interval_traits<Type>::construct(value, value);
}
@@ -188,11 +191,12 @@
template<class Type>
typename enable_if<has_dynamic_bounds<Type>, Type>::type
-unit_closure(const typename interval_traits<Type>::domain_type& value)
+unit_trail(const typename interval_traits<Type>::domain_type& value)
{
return dynamic_interval_traits<Type>::construct(value, value, interval_bounds::closed());
}
+} //namespace detail
//==============================================================================
//= Construct<Interval> multon
Modified: trunk/boost/icl/concept/interval_associator_base.hpp
==============================================================================
--- trunk/boost/icl/concept/interval_associator_base.hpp (original)
+++ trunk/boost/icl/concept/interval_associator_base.hpp 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -30,7 +30,7 @@
{
typedef typename Type::const_iterator const_iterator;
typedef typename Type::interval_type interval_type;
- return object.find(icl::unit_closure<interval_type>(key_val));
+ return object.find(icl::detail::unit_trail<interval_type>(key_val));
}
template<class Type>
@@ -49,7 +49,7 @@
template<class Type>
typename enable_if<mpl::and_< is_interval_container<Type>
, is_continuous<typename domain_type_of<Type>::type>
- , has_static_bounds<typename interval_type_of<Type>::type>
+ , is_static_right_open<typename interval_type_of<Type>::type>
, boost::detail::is_incrementable<typename domain_type_of<Type>::type>
>
, typename Type::const_iterator>::type
@@ -57,12 +57,34 @@
{
typedef typename Type::const_iterator const_iterator;
typedef typename Type::interval_type interval_type;
- const_iterator collision = object.find(icl::unit_closure<interval_type>(key_val));
- // A part of the cover(key_value)-interval may be found in the container, that
+ const_iterator first_collision = object.lower_bound(icl::detail::unit_trail<interval_type>(key_val));
+ // A part of the unit_trail(key_value)-interval may be found in the container, that
// does not contain key_value. Therefore we have to check for its existence:
- return ( collision == object.end()
- || icl::contains(key_value<Type>(collision), key_val) )
- ? collision
+ return ( first_collision == object.end()
+ || icl::contains(key_value<Type>(first_collision), key_val) )
+ ? first_collision
+ : object.end();
+}
+
+template<class Type>
+typename enable_if<mpl::and_< is_interval_container<Type>
+ , is_continuous<typename domain_type_of<Type>::type>
+ , is_static_left_open<typename interval_type_of<Type>::type>
+ , boost::detail::is_incrementable<typename domain_type_of<Type>::type>
+ >
+ , typename Type::const_iterator>::type
+find(const Type& object, const typename domain_type_of<Type>::type& key_val)
+{
+ typedef typename Type::const_iterator const_iterator;
+ typedef typename Type::interval_type interval_type;
+ const_iterator last_collision = object.upper_bound(icl::detail::unit_trail<interval_type>(key_val));
+ if(last_collision != object.begin())
+ --last_collision;
+ // A part of the unit_trail(key_value)-interval may be found in the container, that
+ // does not contain key_value. Therefore we have to check for its existence:
+ return ( last_collision == object.end()
+ || icl::contains(key_value<Type>(last_collision), key_val) )
+ ? last_collision
: object.end();
}
Modified: trunk/boost/icl/interval_base_map.hpp
==============================================================================
--- trunk/boost/icl/interval_base_map.hpp (original)
+++ trunk/boost/icl/interval_base_map.hpp 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -256,7 +256,6 @@
const_iterator find(const domain_type& key_value)const
{
return icl::find(*this, key_value);
- //CL return _map.find(interval_type(key_value));
}
/** Find the first interval value pair, that collides with interval
Modified: trunk/libs/icl/test/Jamfile.v2
==============================================================================
--- trunk/libs/icl/test/Jamfile.v2 (original)
+++ trunk/libs/icl/test/Jamfile.v2 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -33,11 +33,13 @@
# maps
[ run fastest_interval_map_/fastest_interval_map.cpp ]
+
[ run fast_stat_interval_map_/fast_stat_interval_map.cpp
: : : : interval_map_right_open ]
- #[ run fast_stat_interval_map_/fast_stat_interval_map.cpp
- # : : : <define>BOOST_ICL_CONTINUOUS_STATIC_INTERVAL_DEFAULT=left_open_interval
- # : interval_map_left_open ]
+ [ run fast_stat_interval_map_/fast_stat_interval_map.cpp
+ : : : <define>BOOST_ICL_CONTINUOUS_STATIC_INTERVAL_DEFAULT=left_open_interval
+ : interval_map_left_open ]
+
[ run fastest_interval_map_infix_/fastest_interval_map_infix.cpp ]
[ run fastest_split_interval_map_/fastest_split_interval_map.cpp ]
[ run fastest_split_interval_map_infix_/fastest_split_interval_map_infix.cpp ]
Modified: trunk/libs/icl/test/fast_stat_interval_map_/fast_stat_interval_map.cpp
==============================================================================
--- trunk/libs/icl/test/fast_stat_interval_map_/fast_stat_interval_map.cpp (original)
+++ trunk/libs/icl/test/fast_stat_interval_map_/fast_stat_interval_map.cpp 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -1,5 +1,5 @@
/*-----------------------------------------------------------------------------+
-Copyright (c) 2008-2009: Joachim Faulhaber
+Copyright (c) 2008-2011: Joachim Faulhaber
+------------------------------------------------------------------------------+
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENCE.txt or copy at
@@ -12,6 +12,8 @@
#include "../unit_test_unwarned.hpp"
#define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
+//#define BOOST_ICL_CONTINUOUS_STATIC_INTERVAL_DEFAULT left_open_interval
+
// interval instance types
#include "../test_type_lists.hpp"
#include "../test_value_maker.hpp"
Modified: trunk/libs/icl/test/fast_stat_interval_map_cases.hpp
==============================================================================
--- trunk/libs/icl/test/fast_stat_interval_map_cases.hpp (original)
+++ trunk/libs/icl/test/fast_stat_interval_map_cases.hpp 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -8,7 +8,6 @@
#ifndef BOOST_ICL_FAST_STAT_INTERVAL_MAP_CASES_HPP_JOFA_110301
#define BOOST_ICL_FAST_STAT_INTERVAL_MAP_CASES_HPP_JOFA_110301
-/*
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_fundamentals_4_ordered_types)
{ interval_map_fundamentals_4_ordered_types<INTERVAL_MAP, ordered_type_1, int>();}
@@ -22,24 +21,12 @@
{ interval_map_add_sub_4_bicremental_types<INTERVAL_MAP, bicremental_type_2, int>();}
BOOST_AUTO_TEST_CASE
-(fastest_icl_interval_map_distinct_4_bicremental_types)
-{ interval_map_distinct_4_bicremental_types<INTERVAL_MAP, bicremental_type_3, int>();}
-
-BOOST_AUTO_TEST_CASE
-(fastest_icl_interval_map_distinct_4_bicremental_continuous_types)
-{ interval_map_distinct_4_bicremental_continuous_types<INTERVAL_MAP, continuous_type_1, int>();}
-
-BOOST_AUTO_TEST_CASE
-(fastest_icl_interval_map_isolate_4_bicremental_continuous_types)
-{ interval_map_isolate_4_bicremental_continuous_types<INTERVAL_MAP, continuous_type_2, int>();}
-
-BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_contains_4_bicremental_types)
-{ interval_map_contains_4_bicremental_types<INTERVAL_MAP, bicremental_type_4, int>();}
+{ interval_map_contains_4_bicremental_types<INTERVAL_MAP, discrete_type_5, int>();}
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_contains_key_objects_4_bicremental_types)
-{ interval_map_contains_key_objects_4_bicremental_types<INTERVAL_MAP, bicremental_type_4, int>();}
+{ interval_map_contains_key_objects_4_bicremental_types<INTERVAL_MAP, discrete_type_4, int>();}
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_operators_4_bicremental_types)
@@ -51,7 +38,7 @@
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_base_erase_4_bicremental_types)
-{ interval_map_base_erase_4_bicremental_types<INTERVAL_MAP, bicremental_type_7, int>();}
+{ interval_map_base_erase_4_bicremental_types<INTERVAL_MAP, signed_discrete_type_2, int>();}
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_base_is_disjoint_4_bicremental_types)
@@ -60,7 +47,6 @@
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_flip_4_bicremental_types)
{ interval_map_flip_4_bicremental_types<INTERVAL_MAP, bicremental_type_1, int>();}
-*/
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_find_4_bicremental_types)
@@ -68,12 +54,11 @@
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_find_4_numeric_continuous_types)
-{ interval_map_find_4_numeric_continuous_types<INTERVAL_MAP, double, int>();}
+{ interval_map_find_4_numeric_continuous_types<INTERVAL_MAP, numeric_continuous_type_1, int>();}
-/*
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_set_4_bicremental_types)
-{ interval_map_set_4_bicremental_types<INTERVAL_MAP, bicremental_type_3, int>();}
+{ interval_map_set_4_bicremental_types<INTERVAL_MAP, discrete_type_3, int>();}
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_inclusion_compare_4_bicremental_types)
@@ -81,7 +66,7 @@
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_std_copy_via_inserter_4_bicremental_types)
-{ interval_map_std_copy_via_inserter_4_bicremental_types<bicremental_type_4, int, partial_absorber, INTERVAL_MAP>();}
+{ interval_map_std_copy_via_inserter_4_bicremental_types<signed_bicremental_type_1, int, partial_absorber, INTERVAL_MAP>();}
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_element_iter_4_discrete_types)
@@ -89,8 +74,8 @@
BOOST_AUTO_TEST_CASE
(fastest_icl_interval_map_intersects_4_bicremental_types)
-{ interval_map_intersects_4_bicremental_types<INTERVAL_MAP, bicremental_type_3, int>();}
-*/
+{ interval_map_intersects_4_bicremental_types<INTERVAL_MAP, discrete_type_3, int>();}
+
#endif // BOOST_ICL_FAST_STAT_INTERVAL_MAP_CASES_HPP_JOFA_110301
Modified: trunk/libs/icl/test/fastest_icl_interval_/fastest_icl_interval.cpp
==============================================================================
--- trunk/libs/icl/test/fastest_icl_interval_/fastest_icl_interval.cpp (original)
+++ trunk/libs/icl/test/fastest_icl_interval_/fastest_icl_interval.cpp 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -11,8 +11,6 @@
#include <boost/mpl/list.hpp>
#include "../unit_test_unwarned.hpp"
-//#define BOOST_ICL_USE_STATIC_BOUNDED_INTERVALS
-
// interval instance types
#include "../test_type_lists.hpp"
#include "../test_value_maker.hpp"
Modified: trunk/libs/icl/test/test_icl_interval.hpp
==============================================================================
--- trunk/libs/icl/test/test_icl_interval.hpp (original)
+++ trunk/libs/icl/test/test_icl_interval.hpp 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -97,9 +97,9 @@
//JODO BOOST_CHECK( is_incremental_coverable<IntervalT>::value );
BOOST_CHECK( has_difference<T>::value );
- BOOST_CHECK_EQUAL( icl::contains(icl::unit_closure<IntervalT>(MK_v(4)), MK_v(4)), true );
- BOOST_CHECK_EQUAL( icl::length (icl::unit_closure<IntervalT>(MK_v(3))), d_1 );
- BOOST_CHECK ( icl::touches (icl::unit_closure<IntervalT>(MK_v(2)), icl::unit_closure<IntervalT>(MK_v(3))) );
+ BOOST_CHECK_EQUAL( icl::contains(icl::detail::unit_trail<IntervalT>(MK_v(4)), MK_v(4)), true );
+ BOOST_CHECK_EQUAL( icl::length (icl::detail::unit_trail<IntervalT>(MK_v(3))), d_1 );
+ BOOST_CHECK ( icl::touches (icl::detail::unit_trail<IntervalT>(MK_v(2)), icl::detail::unit_trail<IntervalT>(MK_v(3))) );
}
Modified: trunk/libs/icl/test/test_interval_map_shared.hpp
==============================================================================
--- trunk/libs/icl/test/test_interval_map_shared.hpp (original)
+++ trunk/libs/icl/test/test_interval_map_shared.hpp 2011-03-02 09:04:10 EST (Wed, 02 Mar 2011)
@@ -208,13 +208,19 @@
_I4_4I_u2.insert(I4_4I_u2).insert(I4_4I_u2);
BOOST_CHECK_EQUAL( _I4_4I_u2, _I4_4I_u2_1 );
- BOOST_CHECK_EQUAL( cardinality(_I4_4I_u2), unit_element<typename IntervalMapT::size_type>::value() );
- BOOST_CHECK_EQUAL( _I4_4I_u2.size(), unit_element<typename IntervalMapT::size_type>::value() );
+ BOOST_CHECK_EQUAL( cardinality(_I4_4I_u2), unit_element<typename IntervalMapT::size_type>::value() );
+ BOOST_CHECK_EQUAL( _I4_4I_u2.size(), unit_element<typename IntervalMapT::size_type>::value() );
BOOST_CHECK_EQUAL( interval_count(_I4_4I_u2), 1 );
- BOOST_CHECK_EQUAL( _I4_4I_u2.iterative_size(), 1 );
+ BOOST_CHECK_EQUAL( _I4_4I_u2.iterative_size(), 1 );
BOOST_CHECK_EQUAL( iterative_size(_I4_4I_u2), 1 );
- BOOST_CHECK_EQUAL( hull(_I4_4I_u2).lower(), v4 );
- BOOST_CHECK_EQUAL( hull(_I4_4I_u2).upper(), v4 );
+
+ if(has_dynamic_bounds<IntervalT>::value)
+ {
+ BOOST_CHECK_EQUAL( hull(_I4_4I_u2).lower(), v4 );
+ BOOST_CHECK_EQUAL( hull(_I4_4I_u2).upper(), v4 );
+ }
+ BOOST_CHECK_EQUAL( icl::first(hull(_I4_4I_u2)), v4 );
+ BOOST_CHECK_EQUAL( icl::last(hull(_I4_4I_u2)), v4 );
IntervalMapT _I4_4I_u2_copy(_I4_4I_u2);
IntervalMapT _I4_4I_u2_assigned;
@@ -1207,21 +1213,28 @@
BOOST_CHECK_EQUAL( found1->second, found2->second );
BOOST_CHECK_EQUAL( found1->second, MK_u(2) );
- found1 = map_a.find(MK_v(0));
- found2 = icl::find(map_a, MK_v(0));
- BOOST_CHECK ( found1 == found2 );
- BOOST_CHECK ( found1 == map_a.end() );
+ if( mpl::or_<mpl::not_<is_static_left_open<IntervalT> >, is_signed<T> >::value )
+ {
+ found1 = map_a.find(MK_v(0));
+ found2 = icl::find(map_a, MK_v(0));
+ BOOST_CHECK ( found1 == found2 );
+ BOOST_CHECK ( found1 == map_a.end() );
+ }
found1 = map_a.find(MK_v(1));
found2 = icl::find(map_a, MK_v(1));
BOOST_CHECK ( found1 == found2 );
BOOST_CHECK ( found1 == map_a.end() );
- BOOST_CHECK( !icl::contains(map_a, MK_v(0)) );
+ if( mpl::or_<mpl::not_<is_static_left_open<IntervalT> >, is_signed<T> >::value )
+ {
+ BOOST_CHECK( !icl::contains(map_a, MK_v(0)) );
+ }
BOOST_CHECK( icl::contains(map_a, q_1_2) );
BOOST_CHECK( !icl::contains(map_a, MK_v(1)) );
BOOST_CHECK( icl::contains(map_a, q_3_2) );
BOOST_CHECK( !icl::contains(map_a, MK_v(2)) );
+
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk