Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r51211 - sandbox/itl/boost/itl
From: afojgo_at_[hidden]
Date: 2009-02-12 04:19:28


Author: jofaber
Date: 2009-02-12 04:19:27 EST (Thu, 12 Feb 2009)
New Revision: 51211
URL: http://svn.boost.org/trac/boost/changeset/51211

Log:
Reviewed Documentation. Reworked interval_base_{set,map} introducing element_ and segment_type.
Stable {msvc-9.0, partly congcc-4.3-a7}

Text files modified:
   sandbox/itl/boost/itl/interval.hpp | 2
   sandbox/itl/boost/itl/interval_base_map.hpp | 192 ++++++++++++++++-----------------------
   sandbox/itl/boost/itl/interval_base_set.hpp | 150 ++++++++++++++++---------------
   3 files changed, 158 insertions(+), 186 deletions(-)

Modified: sandbox/itl/boost/itl/interval.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval.hpp (original)
+++ sandbox/itl/boost/itl/interval.hpp 2009-02-12 04:19:27 EST (Thu, 12 Feb 2009)
@@ -483,7 +483,7 @@
         //= Representation
         //==========================================================================
         
- /** Interval as string */
+ /** Object as string */
     const std::string as_string()const;
 
 

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-12 04:19:27 EST (Thu, 12 Feb 2009)
@@ -20,7 +20,6 @@
 #include <boost/itl/map.hpp>
 #include <boost/itl/interval_base_set.hpp>
 #include <boost/itl/interval_sets.hpp>
-//CL #include <boost/itl/interval.hpp>
 
 
 #define const_FOR_IMPLMAP(iter) for(typename ImplMapT::const_iterator iter=_map.begin(); (iter)!=_map.end(); (iter)++)
@@ -44,7 +43,7 @@
 
 
 
-/// Implements a map as a map of intervals (base class)
+/** Implements a map as a map of intervals (base class) */
 template
 <
     class SubType,
@@ -169,30 +168,35 @@
         //==========================================================================
         //= Construct, copy, destruct
         //==========================================================================
- /// Default constructor for the empty object
+ /** Default constructor for the empty object */
     interval_base_map(){}
 
- /// Copy constructor
+ /** Copy constructor */
     interval_base_map(const interval_base_map& src): _map(src._map) {}
 
- /// Assignment operator
+ /** Assignment operator */
     interval_base_map& operator = (const interval_base_map& src)
     {
         if(this!=&src) that()->assign(src);
         return *this;
     }
 
- /// swap the content of containers
- void swap(interval_base_map& x) { _map.swap(x._map); }
+ /** swap the content of containers */
+ void swap(interval_base_map& object) { _map.swap(object._map); }
+
+ /** Copy all elements if predicate <tt>pred</tt> holds */
+ template<class Predicate>
+ interval_base_map& assign_if(const interval_base_map& src, const Predicate& pred)
+ { _map.assign_if(src._map, pred); return *this; }
 
         //==========================================================================
         //= Emptieness, containment
         //==========================================================================
 
- /// clear the map
+ /** clear the map */
     void clear() { _map.clear(); }
 
- /// is the map empty?
+ /** is the map empty? */
     bool empty()const { return _map.empty(); }
 
     //--- contains: set view ---------------------------------------------------
@@ -210,15 +214,16 @@
                                                               key_value_pair.data));
         }
 
- /// Does the map contain all element value pairs represented by the interval-value pair sub?
- bool contains(const value_type& sub)const
- { return that()->contains_(sub); }
+ /** Does the map contain all element value pairs represented by the
+ \c interval_value_pair ? */
+ bool contains(const segment_type& interval_value_pair)const
+ { return that()->contains_(interval_value_pair); }
 
     /** Does <tt>*this</tt> container contain <tt>sub</tt>? */
     bool contains(const interval_base_map& sub)const
     { return sub.contained_in(*this); }
 
- /// <tt>*this</tt> is subset of <tt>super</tt>
+ /** <tt>*this</tt> is subset of <tt>super</tt>? */
     bool contained_in(const interval_base_map& super)const
         {
                 return Interval_Set::is_contained_in(*this, super);
@@ -228,30 +233,32 @@
         //= Size
         //==========================================================================
 
- /// Number of elements in the map (cardinality).
+ /** Number of elements in the map (cardinality). */
     size_type cardinality()const;
 
- /// An interval map's size is it's cardinality
+ /** An interval map's size is it's cardinality */
     size_type size()const { return cardinality(); }
 
- /// The length of the interval container which is the sum of interval lenghts
+ /** The length of the interval container which is the sum of
+ interval lenghts */
     difference_type length()const;
 
- /// Number of intervals which is also the size of the iteration over the object
+ /** Number of intervals which is also the size of the
+ iteration over the object */
     size_t interval_count()const { return _map.size(); }
 
- /// Size of the iteration over this container
+ /** Size of the iteration over this container */
     size_t iterative_size()const { return _map.size(); }
 
         //==========================================================================
         //= Range
         //==========================================================================
 
- /// Lower bound of the first interval
+ /** Lower bound of the first interval */
     DomainT lower()const
     { return empty()? interval_type().lower() : (*(_map.begin())).KEY_VALUE.lower(); }
 
- /// Upper bound of the last interval
+ /** Upper bound of the last interval */
     DomainT upper()const
     { return empty()? interval_type().upper() : (*(_map.rbegin())).KEY_VALUE.upper(); }
 
@@ -270,18 +277,17 @@
         //= Selection
         //==========================================================================
 
- //--- find -----------------------------------------------------------------
- /// Find the interval value pair, that contains element \c x
- const_iterator find(const domain_type& key_value)const
+ /** Find the interval value pair, that contains \c key */
+ const_iterator find(const domain_type& key)const
     {
- const_iterator it = _map.find(interval_type(key_value));
+ const_iterator it = _map.find(interval_type(key));
         return it;
     }
 
         /** Total select function. */
- codomain_type operator()(const domain_type& key_value)const
+ codomain_type operator()(const domain_type& key)const
         {
- const_iterator it = _map.find(interval_type(key_value));
+ const_iterator it = _map.find(interval_type(key));
                 return it==end() ? neutron<codomain_type>::value()
                                      : it->CONT_VALUE;
         }
@@ -292,7 +298,7 @@
         //==========================================================================
 private:
         /** Addition of an interval value pair to the map.
- On overlap an aggregation is performed using functor `Combiner`.
+ On overlap an aggregation is performed using functor \c Combiner.
                 This function is not public, because the `codomain_combine` shall be
                 an invariant for all itl maps.*/
     template<class Combiner>
@@ -313,7 +319,7 @@
         //==========================================================================
 private:
         /** Subtraction of an interval value pair from the map.
- On overlap an aggregation is performed using functor `Combiner`.
+ On overlap an aggregation is performed using functor Combiner.
                 This function is not public, because the `codomain_combine` shall be
                 an invariant for all itl maps.*/
     template<class Combiner>
@@ -416,18 +422,17 @@
     /** Erase all value pairs from \c *this map that are elements of map \eraser */
     SubType& erase(const interval_base_map& eraser);
 
+
+ /** Remove all elements where property <tt>p</tt> holds, keep all others */
+ template<class Predicate>
+ interval_base_map& erase_if(const Predicate& pred)
+ { _map.erase_if(pred); return *this; }
+
+
         //==========================================================================
         //= Intersection
         //==========================================================================
 
- //CL Intersect the sectant with *this. Pass the result to section.
- //template<class SectantT>
- //void intersect(interval_base_map& section, const SectantT& sectant)const
- //{
- // section.clear();
- // add_intersection(section, sectant);
- //}
-
         /** The intersection of \c key in \c *this map is added to \c section.
             This can also be used to find \c key in \c *this map */
     void add_intersection(interval_base_map& section, const domain_type& key)const
@@ -526,31 +531,32 @@
     const_iterator upper_bound(const key_type& interval)const
     { return _map.upper_bound(interval); }
 
- ///
     iterator begin() { return _map.begin(); }
- ///
     iterator end() { return _map.end(); }
- ///
     const_iterator begin()const { return _map.begin(); }
- ///
     const_iterator end()const { return _map.end(); }
- ///
     reverse_iterator rbegin() { return _map.rbegin(); }
- ///
     reverse_iterator rend() { return _map.rend(); }
- ///
     const_reverse_iterator rbegin()const { return _map.rbegin(); }
- ///
     const_reverse_iterator rend()const { return _map.rend(); }
 
         //==========================================================================
+ //= Representation
+ //==========================================================================
+
+ /** Object as string */
+ std::string as_string()const;
+
+
+ //==========================================================================
         //= Morphisms
         //==========================================================================
 
- /// Removal of neutral element values
+ /** Join bounding intervals */
+ interval_base_map& join();
+
     /** All value pairs \c (I,y) that have neutral elements \c y==codomain_type()
- as associated values are removed form the map.
- */
+ as associated values are removed form the map. */
     void absorb_neutrons()
     {
         //content_is_neutron<key_type, data_type> neutron_dropper;
@@ -558,11 +564,22 @@
             erase_if(content_is_neutron<value_type>());
     }
 
- /// Join bounding intervals
- interval_base_map& join();
-
+ /** Set all intervals in the map to be of type <tt>bounded</tt>.
+ Requires Integral<domain_type>.
 
- /// Gives the domain of the map as interval set
+ Interval bounds of different types are created by opeations on
+ interval maps. This function allows to reset them uniformly without,
+ of course, changing their value. This is only possible for discrete
+ domain datatypes.
+ */
+ void uniform_bounds(itl::bound_type bounded);
+
+
+ //==========================================================================
+ //= Domain, sum
+ //==========================================================================
+
+ /** Gives the domain of the map as interval set */
     template
     <
         template
@@ -576,66 +593,17 @@
             dom += (*it).KEY_VALUE;
     }
 
-
+ /* Sum of associated elements of the map */
+ void sum(codomain_type& total)const;
 
+ /* Sum of associated elements of the map */
+ codomain_type sum()const
+ { codomain_type total; sum(total); return total; }
 
-/** @name I: Interval search
- */
-//@{
- /** A find function has <b>NOT</b> been implemented; Use \ref intersect
- as a generalized find operation on interval maps.
-
- All find operations can be expressed by means of intersection \ref intersect
- or \ref operator &=. Searching for an interval in an interval map yields
- an interval map anyway in the general case.
- */
-//@}
-
-
-
-/** @name K: Selection by predicates
- */
-//@{
- /// Remove all elements where property <tt>p</tt> holds, keep all others
- template<class Predicate>
- interval_base_map& erase_if(const Predicate& pred)
- { _map.erase_if(pred); return *this; }
-
- /// Copy all elements if property <tt>p</tt> holds
- template<class Predicate>
- interval_base_map& assign_if(const interval_base_map& src, const Predicate& pred)
- { _map.assign_if(src._map, pred); return *this; }
-
-//@}
-
-
-/** @name S: String representation
- */
-//@{
- /** Convert the interval map to string (c.f. \ref value)
 
- This string converter is based on a general converter function <tt>as_string</tt>
- and the template class \ref value which serves as base for string
- representation.
- */
- std::string as_string() const;
-//@}
-
-
-
- /* Sum of associated elements of the map
- <b>Nicht getestet</b> */
- CodomainT sum()const;
-
- /** Set all intervals in the map to be of type <tt>bounded</tt>.
- Requires Integral<domain_type>.
-
- Interval bounds of different types are created by opeations on
- interval maps. This function allows to reset them uniformly without,
- of course, changing their value. This is only possible for discrete
- domain datatypes.
- */
- void uniform_bounds(itl::bound_type bounded);
+ //==========================================================================
+ //= Algorithm unifiers
+ //==========================================================================
 
     template<typename IteratorT>
     static const key_type& key_value(IteratorT& value_){ return (*value_).first; }
@@ -1047,12 +1015,12 @@
     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
>
-CodomainT interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>::sum()const
+void interval_base_map<SubType,DomainT,CodomainT,Traits,Compare,Combine,Section,Interval,Alloc>
+ ::sum(codomain_type& total)const
 {
- CodomainT sum = codomain_combine::neutron();
+ total = codomain_combine::neutron();
     const_FOR_IMPLMAP(it)
- sum += (*it).CONT_VALUE;
- return sum;
+ total += (*it).CONT_VALUE;
 }
 
 

Modified: sandbox/itl/boost/itl/interval_base_set.hpp
==============================================================================
--- sandbox/itl/boost/itl/interval_base_set.hpp (original)
+++ sandbox/itl/boost/itl/interval_base_set.hpp 2009-02-12 04:19:27 EST (Thu, 12 Feb 2009)
@@ -23,7 +23,7 @@
 namespace boost{namespace itl
 {
 
-/// Implements a set as a set of intervals (base class)
+/** Implements a set as a set of intervals (base class) */
 template
 <
     typename SubType,
@@ -125,39 +125,41 @@
         //==========================================================================
         //= Construct, copy, destruct
         //==========================================================================
- /// Default constructor for the empty object
+ /** Default constructor for the empty object */
     interval_base_set(){}
 
- /// Copy constructor
+ /** Copy constructor */
     interval_base_set(const interval_base_set& src): _set()
     { that()->assign(src); }
 
- /// Assignment operator
+ /** Assignment operator */
     interval_base_set& operator = (const interval_base_set& src)
     {
         if(this!=&src) that()->assign(src);
         return *this;
     }
 
+ /** swap the content of containers */
     void swap(interval_base_set& x) { _set.swap(x._set); }
 
         //==========================================================================
         //= Emptieness, containment
         //==========================================================================
 
- /// sets the container empty
+ /** sets the container empty */
     void clear() { _set.clear(); }
- /// is the container empty
+ /** is the container empty? */
     bool empty()const { return _set.empty(); }
 
- /// Does the container contain the element \c x
- bool contains(const DomainT& x)const
- { return that()->contains_(interval_type(x)); }
-
- /// Does the container contain the interval x
- bool contains(const interval_type& x)const
- { return that()->contains_(x); }
+ /** Does the container contain the element \c key ? */
+ bool contains(const element_type& key)const
+ { return that()->contains_(interval_type(key)); }
+
+ /** Does the container contain the interval \c inter_val ? */
+ bool contains(const segment_type& inter_val)const
+ { return that()->contains_(inter_val); }
 
+ /** Does the container contain the subcontainer \c sub ? */
     bool contains(const interval_base_set& sub)const
     { return sub.contained_in(*this); }
 
@@ -171,7 +173,7 @@
     bool contains(const IntervalSet<DomainT,Compare,Interval,Alloc>& sub)const
     { return sub.contained_in(*that()); }
 
- /** Is <tt>*this</tt> contained in <tt>super</tt>? */
+ /** Is <tt>*this</tt> container contained in <tt>super</tt>? */
         template
     <
         template<class DomT, ITL_COMPARE Comp,
@@ -191,26 +193,26 @@
         Infinite for continuous domain datatyps */
     size_type cardinality()const;
 
- /// An interval set's size is it's cardinality
+ /** An interval set's size is it's cardinality */
     size_type size()const { return cardinality(); }
 
- /// The length of the interval container which is the sum of interval lenghts
+ /** The length of the interval container which is the sum of interval lenghts */
     difference_type length()const;
 
- /// Number of intervals which is also the size of the iteration over the object
+ /** Number of intervals which is also the size of the iteration over the object */
     std::size_t interval_count()const { return _set.size(); }
 
- /// Size of the iteration over this container
+ /** Size of the iteration over this container */
     std::size_t iterative_size()const { return _set.size(); }
 
         //==========================================================================
         //= Range
         //==========================================================================
 
- /// lower bound of all intervals in the object
+ /** lower bound of all intervals in the object */
     DomainT lower()const
     { return empty()? interval_type().lower() : (*(_set.begin())).lower(); }
- /// upper bound of all intervals in the object
+ /** upper bound of all intervals in the object */
     DomainT upper()const
     { return empty()? interval_type().upper() : (*(_set.rbegin())).upper(); }
 
@@ -228,10 +230,10 @@
         //= Selection
         //==========================================================================
 
- /// Find the interval value pair, that contains element \c x
- const_iterator find(const DomainT& x)const
+ /** Find the interval value pair, that contains element \c key */
+ const_iterator find(const element_type& key)const
     {
- typename ImplSetT::const_iterator it = this->_map.find(interval_type(x));
+ typename ImplSetT::const_iterator it = this->_map.find(interval_type(key));
         return it;
     }
 
@@ -239,56 +241,60 @@
         //= Addition
         //==========================================================================
 
- /// Add a single element \c x to the set
- SubType& add(const DomainT& x)
- { that()->add_(interval_type(x)); return *that(); }
-
- /// Add an interval of elements \c x to the set
- SubType& add(const value_type& x)
- { that()->add_(x); return *that(); }
+ /** Add a single element \c key to the set */
+ SubType& add(const element_type& key)
+ { that()->add_(interval_type(key)); return *that(); }
+
+ /** Add an interval of elements \c inter_val to the set */
+ SubType& add(const segment_type& inter_val)
+ { that()->add_(inter_val); return *that(); }
 
         //==========================================================================
         //= Subtraction
         //==========================================================================
 
- /// Subtract a single element \c x from the set
- SubType& subtract(const DomainT& x)
- { that()->subtract_(interval_type(x)); return *that(); }
-
- /// Subtract an interval of elements \c x from the set
- SubType& subtract(const value_type& x)
- { that()->subtract_(x); return *that(); }
+ /** Subtract a single element \c key from the set */
+ SubType& subtract(const element_type& key)
+ { that()->subtract_(interval_type(key)); return *that(); }
+
+ /** Subtract an interval of elements \c inter_val from the set */
+ SubType& subtract(const segment_type& inter_val)
+ { that()->subtract_(inter_val); return *that(); }
 
         //==========================================================================
         //= Insertion, erasure
         //==========================================================================
 
- /// Insert an element \c x into the set
- SubType& insert(const DomainT& x)
- { return add(interval_type(x)); }
-
- /// Insert an interval of elements \c x to the set
- SubType& insert(const value_type& x)
- { return add(x); }
-
- /// Erase an element \c x from the set
- SubType& erase(const DomainT& x)
- { return subtract(interval_type(x)); }
-
- /// Erase an interval of element \c x from the set
- SubType& erase(const value_type& x)
- { return subtract(x); }
+ /** Insert an element \c key into the set */
+ SubType& insert(const element_type& key)
+ { return add(interval_type(key)); }
+
+ /** Insert an interval of elements \c inter_val to the set */
+ SubType& insert(const segment_type& inter_val)
+ { return add(inter_val); }
+
+ /** Erase an element \c key from the set */
+ SubType& erase(const element_type& key)
+ { return subtract(interval_type(key)); }
+
+ /** Erase an interval of elements \c inter_val from the set */
+ SubType& erase(const segment_type& inter_val)
+ { return subtract(inter_val); }
 
         //==========================================================================
         //= Intersection
         //==========================================================================
 
- void add_intersection(interval_base_set& section, const domain_type& x)const
- { add_intersection(section, interval_type(x)); }
+ /** The intersection of \c key in \c *this set is added to \c section.
+ The function can be used as a find function. */
+ void add_intersection(interval_base_set& section, const element_type& key)const
+ { add_intersection(section, interval_type(key)); }
 
- void add_intersection(interval_base_set& section, const value_type& x)const;
+ /** The intersection of \c inter_val in \c *this set is added to \c section. */
+ void add_intersection(interval_base_set& section, const segment_type& inter_val)const;
 
 
+ /** The intersection of set \c sectant with \c *this set is added to \c section. */
         template
     <
         template<class DomT, ITL_COMPARE Comp,
@@ -306,11 +312,15 @@
         //= Symmetric difference
         //==========================================================================
 
- SubType& flip(const domain_type& x)
- { return flip(interval_type(x)); }
+ /** If \c *this set contains \c key it is erased, otherwise it is added. */
+ SubType& flip(const element_type& key)
+ { return flip(interval_type(key)); }
 
- SubType& flip(const value_type& x);
+ /** If \c *this set contains \c inter_val it is erased, otherwise it is added. */
+ SubType& flip(const segment_type& inter_val);
 
+ /** The intersection of \c *this and \c operand is erased from \c *this.
+ The complemenary elements are added to \c *this. */
         template
     <
         template<class DomT, ITL_COMPARE Comp,
@@ -323,21 +333,13 @@
         //= Iterator related
         //==========================================================================
 
- ///
     iterator begin() { return _set.begin(); }
- ///
     iterator end() { return _set.end(); }
- ///
     const_iterator begin()const { return _set.begin(); }
- ///
     const_iterator end()const { return _set.end(); }
- ///
     reverse_iterator rbegin() { return _set.rbegin(); }
- ///
     reverse_iterator rend() { return _set.rend(); }
- ///
     const_reverse_iterator rbegin()const { return _set.rbegin(); }
- ///
     const_reverse_iterator rend()const { return _set.rend(); }
 
     iterator lower_bound(const value_type& interval)
@@ -407,6 +409,8 @@
     ImplSetT _set;
 } ;
 
+
+
 template
 <
     class SubType, class DomainT,
@@ -488,19 +492,19 @@
 
 template<class SubType,
          class DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
-void interval_base_set<SubType,DomainT,Compare,Interval,Alloc>::add_intersection(interval_base_set& section, const value_type& x)const
+void interval_base_set<SubType,DomainT,Compare,Interval,Alloc>::add_intersection(interval_base_set& section, const segment_type& inter_val)const
 {
     // any intersection with the empty intervall is empty
- if(x.empty())
+ if(inter_val.empty())
         return;
 
- typename ImplSetT::const_iterator fst_it = _set.lower_bound(x);
- typename ImplSetT::const_iterator end_it = _set.upper_bound(x);
+ typename ImplSetT::const_iterator fst_it = _set.lower_bound(inter_val);
+ typename ImplSetT::const_iterator end_it = _set.upper_bound(inter_val);
 
     for(typename ImplSetT::const_iterator it=fst_it; it != end_it; it++)
     {
         interval_type isec;
- (*it).intersect(isec, x);
+ (*it).intersect(isec, inter_val);
         section.add(isec);
     }
 }
@@ -541,12 +545,12 @@
 template<class SubType,
          class DomainT, ITL_COMPARE Compare, template<class,ITL_COMPARE>class Interval, ITL_ALLOC Alloc>
 SubType& interval_base_set<SubType,DomainT,Compare,Interval,Alloc>
- ::flip(const value_type& x)
+ ::flip(const segment_type& inter_val)
 {
     // That which is common shall be subtracted
         // That which is not shall be added
         // So x has to be 'complementary added' or flipped
- interval_type span = x;
+ interval_type span = inter_val;
     typename ImplSetT::const_iterator fst_ = _set.lower_bound(span);
     typename ImplSetT::const_iterator end_ = _set.upper_bound(span);
 


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