Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50054 - sandbox/itl/boost/itl
From: afojgo_at_[hidden]
Date: 2008-12-01 07:34:49


Author: jofaber
Date: 2008-12-01 07:34:48 EST (Mon, 01 Dec 2008)
New Revision: 50054
URL: http://svn.boost.org/trac/boost/changeset/50054

Log:
Refactored: Combiner functor static instantiation. Step 5. final 1. Removed Nasonov accessor.
Removed non template add_ and subtract_ member functions from derived interval_maps.
Stable {msvc-9.0}
Text files modified:
   sandbox/itl/boost/itl/interval_base_map.hpp | 80 +++------------------------------------
   sandbox/itl/boost/itl/interval_map.hpp | 16 ++-----
   sandbox/itl/boost/itl/split_interval_map.hpp | 26 +++++--------
   3 files changed, 22 insertions(+), 100 deletions(-)

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 2008-12-01 07:34:48 EST (Mon, 01 Dec 2008)
@@ -226,63 +226,6 @@
                               Traits,Compare,Combine,Alloc> atomized_type;
 //@}
 
-private:
- /** access is a technical class that makes protected members of derived classes
- SubType accessible for direct call from the base class. Accessing via
- fuction pointers has been proposed by Alexander Nasonov 2005:
- http://accu.org/index.php/journals/296.
- */
- struct access : SubType
- {
- static bool contains(const SubType& subject, const typename SubType::value_type& operand)
- {
- bool (SubType::*fp)(const typename SubType::value_type&)const = &access::contains_;
- return (subject.*fp)(operand);
- }
-
- template<class OperandT, class Combiner>
- static void add(SubType& subject, const OperandT& operand, const Combiner& combine)
- {
- void (SubType::*fp)(const OperandT&, const Combiner&) = &access::add_;
- (subject.*fp)(operand, combine);
- }
-
- template<class OperandT, class Combiner>
- static void subtract(SubType& subject, const OperandT& operand, const Combiner& combine)
- {
- void (SubType::*fp)(const OperandT&, const Combiner&) = &access::subtract_;
- (subject.*fp)(operand, combine);
- }
-
- template<class OperandT>
- static void add(SubType& subject, const OperandT& operand)
- {
- void (SubType::*fp)(const OperandT&) = &access::add_;
- (subject.*fp)(operand);
- }
-
- template<class OperandT>
- static void subtract(SubType& subject, const OperandT& operand)
- {
- void (SubType::*fp)(const OperandT&) = &access::subtract_;
- (subject.*fp)(operand);
- }
-
- template<class OperandT>
- static void insert(SubType& subject, const OperandT& operand)
- {
- void (SubType::*fp)(const OperandT&) = &access::insert_;
- (subject.*fp)(operand);
- }
-
- template<class OperandT>
- static void erase(SubType& subject, const OperandT& operand)
- {
- void (SubType::*fp)(const OperandT&) = &access::erase_;
- (subject.*fp)(operand);
- }
- };
-
 public:
     inline static bool has_symmetric_difference()
     { return is_set<codomain_type>::value || !traits::absorbs_neutrons || traits::emits_neutrons; }
@@ -330,11 +273,11 @@
     //--- contains: map view ------------------------------------------------------
     /// Does the map contain the element pair <tt>x = (key_element,value)</tt>?
     bool contains(const base_pair_type& x)const
- { return access::contains(*that(), value_type(interval_type(x.key), x.data)); }
+ { return that()->contains_(value_type(interval_type(x.key), x.data)); }
 
     /// Does the map contain all element value pairs represented by the interval-value pair sub?
     bool contains(const value_type& sub)const
- { return access::contains(*that(), sub); }
+ { return that()->contains_(sub); }
 
     /** Does <tt>*this</tt> container contain <tt>sub</tt>? */
     bool contains(const interval_base_map& sub)const
@@ -421,14 +364,6 @@
         { that()->template add_<Combiner>(x); return *that(); }
 
 public:
- //template<class Combiner>
- //CL? SubType& add(const value_type& x)
- //{ access::add(*that(), x, mpl::apply<Combiner,CodomainT>::type()); return *that(); };
-
- //template<ITL_COMBINE Combiner>
- //CL? SubType& add(const value_type& x)
- //{ access::add(*that(), x, Combiner<CodomainT>()); return *that(); };
-
     /// Addition of a base value pair.
     /** Addition of a base value pair <tt>x := pair(k,y)</tt> where <tt>base_value_type:=pair<DomainT,CodomainT></tt>
     
@@ -460,7 +395,6 @@
     */
     SubType& add(const value_type& x)
         { that()->template add_<Combine<CodomainT> >(x); return *that(); }
- //CL { access::add(*that(), x, Combine<CodomainT>()); return *that(); }
 //@}
 
 
@@ -561,7 +495,7 @@
     */
     SubType& insert(const base_pair_type& x)
     {
- access::insert(*that(), value_type(interval_type(x.key), x.data) );
+ that()->insert_(value_type(interval_type(x.key), x.data) );
         return *that();
     }
 
@@ -577,7 +511,7 @@
         \c insert(x) is equivalent to \c add<inplace_identity>(x)
     */
     SubType& insert(const value_type& x)
- { access::insert(*that(), x); return *that(); }
+ { that()->insert_(x); return *that(); }
 
     /// Erase a base value pair from the map
     /** Erase a base value pair <tt>x=(k,y)</tt>.
@@ -586,7 +520,7 @@
     */
     SubType& erase(const base_pair_type& x)
     {
- access::erase(*that(), value_type(interval_type(x.key), x.data));
+ that()->erase_(value_type(interval_type(x.key), x.data));
         return *that();
     }
 
@@ -600,7 +534,7 @@
         \c erase(x) is equivalent to \c subtract<inplace_erasure>(x)
     */
     SubType& erase(const value_type& x)
- { access::erase(*that(), x); return *that(); }
+ { that()->erase_(x); return *that(); }
 
 
     /// Erase an associated value for a key
@@ -1237,7 +1171,7 @@
     ::erase(const interval_base_map& erasure)
 {
     const_FORALL(typename interval_base_map, value_pair_, erasure)
- access::erase(*that(), *value_pair_);
+ that()->erase_(*value_pair_);
 
     return *that();
 }

Modified: sandbox/itl/boost/itl/interval_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_map.hpp (original)
+++ sandbox/itl/boost/itl/interval_map.hpp 2008-12-01 07:34:48 EST (Mon, 01 Dec 2008)
@@ -176,6 +176,11 @@
     }
  
 private:
+ // The following _suffixed function templates funx_ are implementations
+ // correspoding unsuffixed function templates funx of the base class.
+ // For funx_ want to be used in the base class via derived SubType pointer:
+ // that()->funx_. So they must be either public or made accessible by a
+ // friend declaration:
         friend class base_type;
 
     bool contains_(const value_type& x)const;
@@ -183,20 +188,9 @@
     template<class Combiner>
     void add_(const value_type&);
 
- void add_(const value_type& value)
- { add_<Combine<CodomainT> >(value); }
-
     template<class Combiner>
     void subtract_(const value_type&);
 
- void subtract_(const value_type& value)//JODO
- {
- if(Traits::emits_neutrons)
- add_<inplace_minus<CodomainT> >(value);
- else
- subtract_<inplace_minus<CodomainT> >(value);
- }
-
     void insert_(const value_type& value);
     void erase_(const value_type& value);
 

Modified: sandbox/itl/boost/itl/split_interval_map.hpp
==============================================================================
--- sandbox/itl/boost/itl/split_interval_map.hpp (original)
+++ sandbox/itl/boost/itl/split_interval_map.hpp 2008-12-01 07:34:48 EST (Mon, 01 Dec 2008)
@@ -190,6 +190,11 @@
         }
 
         private:
+ // The following _suffixed function templates funx_ are implementations
+ // correspoding unsuffixed function templates funx of the base class.
+ // For funx_ want to be used in the base class via derived SubType pointer:
+ // that()->funx_. So they must be either public or made accessible by a
+ // friend declaration:
                 friend class base_type;
 
         bool contains_(const value_type& x)const;
@@ -197,20 +202,9 @@
         template<class Combiner>
         void add_(const value_type&);
 
- void add_(const value_type& value)
- { add_<inplace_plus<CodomainT> >(value); }
-
         template<class Combiner>
         void subtract_(const value_type&);
 
- void subtract_(const value_type& value)//JODO
- {
- if(Traits::emits_neutrons)
- add_<inplace_minus<CodomainT> >(value);
- else
- subtract_<inplace_minus<CodomainT> >(value);
- }
-
         void insert_(const value_type& value);
         void erase_(const value_type& value);
 
@@ -582,7 +576,7 @@
 
         interval_type leadGap; x_itv.left_surplus(leadGap, fst_itv);
         // this is a new Interval that is a gap in the current map
- fill_gap<inplace_plus<CodomainT> >(value_type(leadGap, x_val));
+ fill_gap<Combine<CodomainT> >(value_type(leadGap, x_val));
 
         // only for the first there can be a leftResid: a part of *it left of x
         interval_type leftResid; fst_itv.left_surplus(leftResid, x_itv);
@@ -597,7 +591,7 @@
         {
             interval_type endGap; x_itv.right_surplus(endGap, fst_itv);
             // this is a new Interval that is a gap in the current map
- fill_gap<inplace_plus<CodomainT> >(value_type(endGap, x_val));
+ fill_gap<Combine<CodomainT> >(value_type(endGap, x_val));
         }
         else
         {
@@ -624,7 +618,7 @@
     {
         cur_itv = (*it).KEY_VALUE ;
         x_rest.left_surplus(gap, cur_itv);
- fill_gap<inplace_plus<CodomainT> >(value_type(gap, x_val));
+ fill_gap<Combine<CodomainT> >(value_type(gap, x_val));
         // shrink interval
         x_rest.left_subtract(cur_itv);
     }
@@ -642,14 +636,14 @@
 
     interval_type left_gap;
     x_rest.left_surplus(left_gap, cur_itv);
- fill_gap<inplace_plus<CodomainT> >(value_type(left_gap, x_val));
+ fill_gap<Combine<CodomainT> >(value_type(left_gap, x_val));
 
     interval_type common;
     cur_itv.intersect(common, x_rest);
 
     interval_type end_gap;
     x_rest.right_surplus(end_gap, cur_itv);
- fill_gap<inplace_plus<CodomainT> >(value_type(end_gap, x_val));
+ fill_gap<Combine<CodomainT> >(value_type(end_gap, x_val));
 }
 
 


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