|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r51191 - in sandbox/itl: boost/itl libs/itl/example/interval_container
From: afojgo_at_[hidden]
Date: 2009-02-10 18:16:08
Author: jofaber
Date: 2009-02-10 18:16:07 EST (Tue, 10 Feb 2009)
New Revision: 51191
URL: http://svn.boost.org/trac/boost/changeset/51191
Log:
Refactored. Made map::add<F> and map::subtract<F> private. Added map::add_intersection.
Stable {msvc-9.0, partly congcc-4.3-a7}
Text files modified:
sandbox/itl/boost/itl/interval.hpp | 38 ++--------
sandbox/itl/boost/itl/interval_base_map.hpp | 16 ----
sandbox/itl/boost/itl/map.hpp | 143 +++++++++++++++++++++++++++++----------
sandbox/itl/libs/itl/example/interval_container/interval_container.cpp | 8 +-
4 files changed, 118 insertions(+), 87 deletions(-)
Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2009-02-10 18:16:07 EST (Tue, 10 Feb 2009)
@@ -1,32 +1,12 @@
-/*----------------------------------------------------------------------------+
-Copyright (c) 2007-2008: Joachim Faulhaber
-+-----------------------------------------------------------------------------+
+/*-----------------------------------------------------------------------------+
+Author: Joachim Faulhaber
+Copyright (c) 2007-2009: Joachim Faulhaber
Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
-+-----------------------------------------------------------------------------+
-Boost Software License - Version 1.0 - August 17th, 2003
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-+----------------------------------------------------------------------------*/
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
#ifndef __itl_interval_JOFA_000626_H__
#define __itl_interval_JOFA_000626_H__
@@ -59,8 +39,6 @@
#define BOUND_VAL first
#define BOUND_TYPES second
-typedef unsigned char ITV_BOUNDTYPES; //JODO refa
-
namespace boost{namespace itl
{
Modified: sandbox/itl/boost/itl/interval_base_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_map.hpp 2009-02-10 18:16:07 EST (Tue, 10 Feb 2009)
@@ -934,22 +934,6 @@
-/*CL
-template
-<
- class SubType,
- class DomainT, class CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc
->
-bool interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>::contained_in(const interval_base_map& super)const
-{
- // x2 should be larger than *this; so every element in this should be in x2
- const_FOR_IMPLMAP(it)
- if(!super.contains(*it))
- return false;
- return true;
-}
-*/
-
template
<
class SubType,
Modified: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/map.hpp (original)
+++ sandbox/itl/boost/itl/map.hpp 2009-02-10 18:16:07 EST (Tue, 10 Feb 2009)
@@ -1,35 +1,16 @@
-/*----------------------------------------------------------------------------+
-Copyright (c) 2007-2008: Joachim Faulhaber
-+-----------------------------------------------------------------------------+
-Boost Software License - Version 1.0 - August 17th, 2003
-
-Permission is hereby granted, free of charge, to any person or organization
-obtaining a copy of the software and accompanying documentation covered by
-this license (the "Software") to use, reproduce, display, distribute,
-execute, and transmit the Software, and to prepare derivative works of the
-Software, and to permit third-parties to whom the Software is furnished to
-do so, all subject to the following:
-
-The copyright notices in the Software and this entire statement, including
-the above license grant, this restriction and the following disclaimer,
-must be included in all copies of the Software, in whole or in part, and
-all derivative works of the Software, unless such copies or derivative
-works are solely in the form of machine-executable object code generated by
-a source language processor.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
-SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
-FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-DEALINGS IN THE SOFTWARE.
-+----------------------------------------------------------------------------*/
-/* ------------------------------------------------------------------
+/*-----------------------------------------------------------------------------+
+Copyright (c) 2007-2009: Joachim Faulhaber
++------------------------------------------------------------------------------+
+ Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file LICENCE.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
++-----------------------------------------------------------------------------*/
+
+/*-----------------------------------------------------------------------------+
class itl::map
a general map class that extends stl-maps
for concepts InplaceAddable and InplaceSubtractable
---------------------------------------------------------------------*/
++-----------------------------------------------------------------------------*/
#ifndef __itl_map_h_JOFA_070519__
#define __itl_map_h_JOFA_070519__
@@ -238,6 +219,14 @@
return *this;
}
+ void add_intersection(map& section, const domain_type& key_value)const;
+
+ void add_intersection(map& section, const value_type& value_pair)const;
+
+ void add_intersection(map& section, const set_type& sectant)const;
+
+ void add_intersection(map& section, const map& sectant)const;
+
//JODO
/** erase the value pair \c pair(key,val) from the map.
Erase only if, the exact value content \c val is stored at key \key. */
@@ -293,8 +282,7 @@
/** Represent this map as string */
std::string as_string()const;
- //private:
- public: //JODO private: Problem add<F>(x) is used in set_algo
+ private:
template<class Combiner>
map& add(const value_type& value_pair);
@@ -370,6 +358,79 @@
return *this;
}
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::add_intersection(map& section, const value_type& sectant)const
+ {
+ if(Traits::is_total)
+ {
+ section = *this;
+ section.add(sectant);
+ }
+ else
+ {
+ const_iterator it_ = find(sectant.KEY_VALUE);
+ if(it_ != end())
+ {
+ section.add(*it_);
+ if(is_set<CodomainT>::value)
+ section.template add<codomain_intersect>(sectant);
+ else
+ section.template add<codomain_combine>(sectant);
+ }
+ }
+ }
+
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::add_intersection(map& section, const domain_type& sectant)const
+ {
+ const_iterator it_ = find(sectant);
+ if(it_ != end())
+ add(*it_);
+ }
+
+
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::add_intersection(map& section, const typename map::set_type& sectant)const
+ {
+ typename set_type::const_iterator common_lwb_;
+ typename set_type::const_iterator common_upb_;
+ if(!common_range(common_lwb_, common_upb_, sectant, *this))
+ return;
+
+ typename set_type::const_iterator sec_ = common_lwb_;
+ while(sec_ != common_upb_)
+ add_intersection(*sec_++);
+ }
+
+
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ void map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ ::add_intersection(map& section, const map& sectant)const
+ {
+ const_iterator common_lwb_;
+ const_iterator common_upb_;
+ if(!Set::common_range(common_lwb_, common_upb_, sectant, *this))
+ return;
+
+ typename const_iterator sec_ = common_lwb_;
+ while(sec_ != common_upb_)
+ {
+ const_iterator it_ = find(sec_->KEY_VALUE);
+ if(it_ != end())
+ {
+ section.add(*it_);
+ if(is_set<CodomainT>::value)
+ section.template add<codomain_intersect>(*sec_);
+ else
+ section.template add<codomain_combine>(*sec_);
+ }
+ ++sec_;
+ }
+ }
+
template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
std::string map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::as_string()const
@@ -443,6 +504,7 @@
return object;
}
+
//-----------------------------------------------------------------------------
// non member functions
//-----------------------------------------------------------------------------
@@ -592,10 +654,9 @@
const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
{
typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
- if(Traits::is_total && has_inverse<typename ObjectT::codomain_type>::value)
- const_FORALL(typename ObjectT, it_, operand)
- object.template add<ObjectT::inverse_codomain_combine>(*it_);
- else Set::subtract(object, operand);
+ const_FORALL(typename ObjectT, it_, operand)
+ object.subtract(*it_);
+
return object;
}
@@ -634,8 +695,16 @@
operator &= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
{
+ typedef typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> object_type;
if(Traits::is_total) return object += operand;
- else{ Map::intersect(object, operand); return object; }
+ else
+ {
+ object_type section;
+ object.add_intersection(section, operand);
+ object.swap(section);
+ return object;
+ }
+ //CL{ Map::intersect(object, operand); return object; }
}
template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
@@ -653,7 +722,7 @@
inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
operator &= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
- { Map::intersect(object, operand); return object; }
+ { Map::intersect(object, operand); return object; } //JODO TEST
template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
Modified: sandbox/itl/libs/itl/example/interval_container/interval_container.cpp
==============================================================================
--- sandbox/itl/libs/itl/example/interval_container/interval_container.cpp (original)
+++ sandbox/itl/libs/itl/example/interval_container/interval_container.cpp 2009-02-10 18:16:07 EST (Tue, 10 Feb 2009)
@@ -1,13 +1,13 @@
-/*----------------------------------------------------------------------------+
+/*-----------------------------------------------------------------------------+
Interval Template Library
Author: Joachim Faulhaber
-Copyright (c) 2007-2008: Joachim Faulhaber
+Copyright (c) 2007-2009: Joachim Faulhaber
Copyright (c) 1999-2006: Cortex Software GmbH, Kantstrasse 57, Berlin
-+-----------------------------------------------------------------------------+
++------------------------------------------------------------------------------+
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENCE.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
-+----------------------------------------------------------------------------*/
++-----------------------------------------------------------------------------*/
/** Example interval_container.cpp \file interval_container.cpp
Sample file interval_container.cpp demontrates basic charactersistics of
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