Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r50610 - in sandbox/itl: boost/itl libs/itl/doc
From: afojgo_at_[hidden]
Date: 2009-01-15 10:43:31


Author: jofaber
Date: 2009-01-15 10:43:30 EST (Thu, 15 Jan 2009)
New Revision: 50610
URL: http://svn.boost.org/trac/boost/changeset/50610

Log:
Refactored. Made set::ops o= non member, added .o. operators. Stable {msvc-9.0, partly congcc-4.3-a7}

Text files modified:
   sandbox/itl/boost/itl/map.hpp | 181 +++++++++++++++++++++-------
   sandbox/itl/boost/itl/set.hpp | 251 ++++++++++++++++++++++++++++-----------
   sandbox/itl/libs/itl/doc/interface.qbk | 16 +
   3 files changed, 324 insertions(+), 124 deletions(-)

Modified: sandbox/itl/boost/itl/map.hpp
==============================================================================
--- sandbox/itl/boost/itl/map.hpp (original)
+++ sandbox/itl/boost/itl/map.hpp 2009-01-15 10:43:30 EST (Thu, 15 Jan 2009)
@@ -235,42 +235,11 @@
                         return *this;
                 }
 
-
- /** Subtract a map \c x2 from this map. If an element of \c x2 already exists
- in \c *this, subtract the contents using <tt>operator -=</tt>. */
- map& operator -= (const map& x2)
- {
- if(Traits::emits_neutrons && !is_set<codomain_type>::value)
- const_FORALL(typename map, it_, x2)
- this->add<inverse_codomain_combine>(*it_);
- else Set::subtract(*this, x2);
- return *this;
- }
-
- /** Subtract a set \c x2 from this map. Every element of \c this map that
- has a key that is element of \c x2 is deleted from the map. */
- map& operator -= (const set_type& x2) { Set::erase(*this, x2); return *this; }
-
-
         //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. */
         size_type erase(const value_type& value);
 
- //JODO
- /** Intersect map \c x2 and \c *this.
- So \c *this becomes the intersection of \c *this and \c x2 */
- map& operator &= (const map& x2)
- {
- if(Traits::emits_neutrons) return *this += x2;
- else{ Map::intersect(*this, x2); return *this; }
- }
-
- /** Intersect set \c x2 and \c *this.
- So \c *this becomes the intersection of \c *this and \c x2 */
- map& operator &= (const set_type& x2)
- { Map::intersect(*this, x2); return *this; }
-
         /** \c key_value allows for a uniform access to \c key_values which is
             is used for common algorithms on sets and maps. */
         template<typename IteratorT>
@@ -539,13 +508,22 @@
         const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& rhs)
         { return !(lhs < rhs); }
 
- //-----------------------------------------------------------------------------
+ //--------------------------------------------------------------------------
     template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
         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>::value_type& operand)
     { return object.add(operand); }
         
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ operator + ( const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) += operand;
+ }
+
 
     /** Add a map \c operand to map \c object. If an element of \c operand already exists
         in \c object, add up the contents. */
@@ -556,22 +534,133 @@
     { Set::add(object, operand); return object; }
 
 
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ operator + (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) += operand;
+ }
+
+ //--------------------------------------------------------------------------
 
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ 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>::value_type& operand)
+ { return object.add(operand); }
+
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ operator | ( const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::value_type& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) |= operand;
+ }
+
+
+ /** Add a map \c operand to map \c object. If an element of \c operand already exists
+ in \c object, add up the contents. */
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+ operator |= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+ { Set::add(object, operand); return object; }
+
+
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ operator | (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) |= operand;
+ }
 
- /** Subtract a map \c x2 from this map. If an element of \c x2 already exists
- in \c *this, subtract the contents using <tt>operator -=</tt>. */
- // map& operator -= (const map& x2)
- // {
- //if(Traits::emits_neutrons && !is_set<codomain_type>::value)
- // const_FORALL(typename map, it_, x2)
- // this->add<inverse_codomain_combine>(*it_);
- // else Set::subtract(*this, x2);
- // return *this;
- // }
-
- /** Subtract a set \c x2 from this map. Every element of \c this map that
- has a key that is element of \c x2 is deleted from the map. */
- // map& operator -= (const set_type& x2) { Set::erase(*this, x2); return *this; }
+ //--------------------------------------------------------------------------
+
+ /** Subtract a map \c x2 from this map. If an element of \c x2 already exists
+ in \c *this, subtract the contents using <tt>operator -=</tt>. */
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+ operator -= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ if(Traits::emits_neutrons && !is_set<typename ObjectT::codomain_type>::value)
+ const_FORALL(typename ObjectT, it_, operand)
+ object.template add<ObjectT::inverse_codomain_combine>(*it_);
+ else Set::subtract(object, operand);
+ return object;
+ }
+
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ operator - (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) -= operand;
+ }
+
+ /** Subtract a set \c x2 from this map. Every element of \c this map that
+ has a key that is element of \c x2 is deleted from the map. */
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ 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)
+ { Set::erase(object, operand); return object; }
+
+
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ operator - (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) -= operand;
+ }
+
+
+ /** Intersect map \c x2 and \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ inline itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>&
+ operator &= ( itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+ {
+ if(Traits::emits_neutrons) return object += operand;
+ else{ 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>
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ operator & (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) &= operand;
+ }
+
+ /** Intersect set \c x2 and \c *this.
+ So \c *this becomes the intersection of \c *this and \c x2 */
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ 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; }
+
+
+ template <typename DomainT, typename CodomainT, class Traits, ITL_COMPARE Compare, ITL_COMBINE Combine, ITL_SECTION Section, ITL_ALLOC Alloc>
+ itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>
+ operator & (const itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>& object,
+ const typename itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc>::set_type& operand)
+ {
+ typedef itl::map<DomainT,CodomainT,Traits,Compare,Combine,Section,Alloc> ObjectT;
+ return ObjectT(object) &= operand;
+ }
 
 
         //-----------------------------------------------------------------------------

Modified: sandbox/itl/boost/itl/set.hpp
==============================================================================
--- sandbox/itl/boost/itl/set.hpp (original)
+++ sandbox/itl/boost/itl/set.hpp 2009-01-15 10:43:30 EST (Thu, 15 Jan 2009)
@@ -157,22 +157,11 @@
         /** <tt>*this</tt> and <tt>x2</tt> are disjoint, if their intersection is empty */
         bool disjoint(const set& x2)const { return disjoint(*this, x2); }
 
- iterator add(const value_type& vp) { return insert(vp).ITERATOR; }
- set& operator += (const value_type& vp) { insert(vp); return *this; }
+ /** Add an element \c value to the set. */
+ set& add(const value_type& value) { insert(value); return *this; }
 
- // Default subtract-function using -= on CodomTV
- iterator subtract(const value_type& vp);
- set& operator -= (const value_type& vp) { subtract(vp); return *this; }
-
- /// Add a set \c x2 to this set.
- set& operator += (const set& x2) { Set::add(*this, x2); return *this; }
-
- /// Subtract a set \c x2 from this set.
- set& operator -= (const set& x2) { Set::subtract(*this, x2); return *this; }
-
- /** Intersect set \c x2 \c *this.
- So \c *this becomes the intersection of \c *this and \c x2 */
- set& operator &= (const set& x) { Set::intersect(*this, x); return *this; }
+ /** Subtract an element \c value from the set. */
+ set& subtract(const value_type& value);
 
         /** \c key_value allows for a uniform access to \c key_values which is
             is used for common algorithms on sets and maps. */
@@ -217,6 +206,65 @@
     };
 
 
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ set<DomainT,Compare,Alloc>&
+ set<DomainT,Compare,Alloc>::subtract(const value_type& val)
+ {
+ iterator it_ = find(val);
+ if(it_ != end())
+ erase(it_);
+
+ return *this;
+ }
+
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ std::string set<DomainT,Compare,Alloc>::as_string(const char* sep)const
+ {
+ const_iterator it_ = begin();
+
+ if(it_ == end()) return std::string();
+ else
+ {
+ std::string y = to_string<DomainT>::apply(*it_++);
+ while(it_ != end()) { y += sep; y += to_string<DomainT>::apply(*it_++); }
+ return y;
+ }
+ }
+
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ template <class Predicate>
+ set<DomainT,Compare,Alloc>& set<DomainT,Compare,Alloc>
+ ::erase_if(const Predicate& pred)
+ {
+ iterator it = begin();
+ while(it != end())
+ if(pred(*it))
+ erase(it++);
+ else ++it;
+ return *this;
+
+ }
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ template <class Predicate>
+ set<DomainT,Compare,Alloc>& set<DomainT,Compare,Alloc>
+ ::assign_if(const set<DomainT,Compare,Alloc>& src, const Predicate& pred)
+ {
+ clear();
+ const_iterator it = src.begin();
+ while(it != src.end()) {
+ if(pred(*it))
+ add(*it++);
+ }
+ return *this;
+ }
+
+ //-----------------------------------------------------------------------------
+ // non member functions
+ //-----------------------------------------------------------------------------
     /** Standard equality, which is lexicographical equality of the sets
         as sequences, that are given by their Compare order. */
     template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
@@ -258,88 +306,147 @@
     /** Partial ordering which is induced by Compare */
     template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
     inline bool operator <= (const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
+ const itl::set<DomainT,Compare,Alloc>& rhs)
         { return !(lhs > rhs); }
 
     template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
     inline bool operator >= (const itl::set<DomainT,Compare,Alloc>& lhs,
- const itl::set<DomainT,Compare,Alloc>& rhs)
+ const itl::set<DomainT,Compare,Alloc>& rhs)
         { return !(lhs < rhs); }
 
+ //--------------------------------------------------------------------------
 
     template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- typename set<DomainT,Compare,Alloc>::iterator
- set<DomainT,Compare,Alloc>::subtract(const value_type& val)
- {
- iterator it_ = find(val);
- if(it_ != end())
- erase(it_);
+ inline itl::set<DomainT,Compare,Alloc>&
+ operator += ( itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+ { return object.add(operand); }
 
- return end();
- }
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ itl::set<DomainT,Compare,Alloc>
+ operator + (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+ { return itl::set<DomainT,Compare,Alloc>(object) += operand; }
+
+ /// Add a set \c operand to this set \object.
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ inline itl::set<DomainT,Compare,Alloc>&
+ operator += ( itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+ { Set::add(object, operand); return object; }
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ itl::set<DomainT,Compare,Alloc>
+ operator + (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+ { return itl::set<DomainT,Compare,Alloc>(object) += operand; }
 
+ //--------------------------------------------------------------------------
 
     template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- std::string set<DomainT,Compare,Alloc>::as_string(const char* sep)const
- {
- const_iterator it_ = begin();
-
- if(it_ == end()) return std::string();
- else
- {
- std::string y = to_string<DomainT>::apply(*it_++);
- while(it_ != end()) { y += sep; y += to_string<DomainT>::apply(*it_++); }
- return y;
- }
- }
+ inline itl::set<DomainT,Compare,Alloc>&
+ operator |= ( itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+ { return object.add(operand); }
 
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ itl::set<DomainT,Compare,Alloc>
+ operator | (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+ { return itl::set<DomainT,Compare,Alloc>(object) |= operand; }
 
+ /// Add a set \c operand to this set \object.
     template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- template <class Predicate>
- set<DomainT,Compare,Alloc>& set<DomainT,Compare,Alloc>
- ::erase_if(const Predicate& pred)
- {
- iterator it = begin();
- while(it != end())
- if(pred(*it))
- erase(it++);
- else ++it;
- return *this;
+ inline itl::set<DomainT,Compare,Alloc>&
+ operator |= ( itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+ { Set::add(object, operand); return object; }
 
- }
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ itl::set<DomainT,Compare,Alloc>
+ operator | (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+ { return itl::set<DomainT,Compare,Alloc>(object) |= operand; }
+
+ //--------------------------------------------------------------------------
 
     template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
- template <class Predicate>
- set<DomainT,Compare,Alloc>& set<DomainT,Compare,Alloc>
- ::assign_if(const set<DomainT,Compare,Alloc>& src, const Predicate& pred)
+ inline itl::set<DomainT,Compare,Alloc>&
+ operator -= ( itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+ { return object.subtract(operand); }
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ itl::set<DomainT,Compare,Alloc>
+ operator - (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+ { return itl::set<DomainT,Compare,Alloc>(object) -= operand; }
+
+
+ /// Subtract a set \c x2 from this set.
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ inline itl::set<DomainT,Compare,Alloc>&
+ operator -= ( itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+ { Set::subtract(object, operand); return object; }
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ itl::set<DomainT,Compare,Alloc>
+ operator - (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+ { return itl::set<DomainT,Compare,Alloc>(object) -= operand; }
+
+ //--------------------------------------------------------------------------
+ // itl::set::intersection operators &=, &
+ //--------------------------------------------------------------------------
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ inline itl::set<DomainT,Compare,Alloc>&
+ operator &= ( itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
     {
- clear();
- const_iterator it = src.begin();
- while(it != src.end()) {
- if(pred(*it))
- add(*it++);
- }
- return *this;
- }
+ typedef itl::set<DomainT,Compare,Alloc> ObjectT;
+ typename ObjectT::const_iterator element_ = object.find(operand);
+ ObjectT intersection = element_ == object.end() ? ObjectT()
+ : ObjectT(*element_);
+ object.swap(intersection);
+ return object;
+ }
 
- //-------------------------------------------------------------------------
- template <typename DomainT,
- ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ itl::set<DomainT,Compare,Alloc>
+ operator & (const itl::set<DomainT,Compare,Alloc>& object,
+ const typename itl::set<DomainT,Compare,Alloc>::value_type& operand)
+ { return itl::set<DomainT,Compare,Alloc>(object) &= operand; }
+
+
+
+ /** Intersect set \c object with \c operand.
+ So \c object becomes the intersection of \c object and \c operand */
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ inline itl::set<DomainT,Compare,Alloc>&
+ operator &= ( itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+ { Set::intersect(object, operand); return object; }
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ itl::set<DomainT,Compare,Alloc>
+ operator & (const itl::set<DomainT,Compare,Alloc>& object,
+ const itl::set<DomainT,Compare,Alloc>& operand)
+ { return itl::set<DomainT,Compare,Alloc>(object) &= operand; }
+
+
+
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
     set<DomainT,Compare,Alloc>&
         insert( set<DomainT,Compare,Alloc>& object,
- const set<DomainT,Compare,Alloc>& insertee)
- {
- return object += insertee;
- }
+ const set<DomainT,Compare,Alloc>& operand)
+ { return object += operand; }
 
- template <typename DomainT,
- ITL_COMPARE Compare, ITL_ALLOC Alloc>
+ template <typename DomainT, ITL_COMPARE Compare, ITL_ALLOC Alloc>
     set<DomainT,Compare,Alloc>&
         erase( set<DomainT,Compare,Alloc>& object,
- const set<DomainT,Compare,Alloc>& erasee)
- {
- return object -= erasee;
- }
+ const set<DomainT,Compare,Alloc>& operand)
+ { return object -= operand; }
 
 
 

Modified: sandbox/itl/libs/itl/doc/interface.qbk
==============================================================================
--- sandbox/itl/libs/itl/doc/interface.qbk (original)
+++ sandbox/itl/libs/itl/doc/interface.qbk 2009-01-15 10:43:30 EST (Thu, 15 Jan 2009)
@@ -385,9 +385,13 @@
 [[`difference_type T::length()const`] [1] [1] [1] [ ] [ ] [ ] [ ]]
 [[`size_t T::iterative_size()const`] [1] [1] [1] [1] [1] [ ] [ ]]
 [[`size_t T::interval_count()const`] [1] [1] [1] [ ] [ ] [ ] [ ]]
-[[['*Range*]] [interval][interval\nsets][interval\nmaps][itl::set][itl::map][std::set][std::map]]
+[[['*Range*]] [ ] [ ] [ ] [ ] [ ] [ ] [ ]]
 [[`domain_type T::lower()const`] [1] [1] [1] [ ] [ ] [ ] [ ]]
 [[`domain_type T::upper()const`] [1] [1] [1] [ ] [ ] [ ] [ ]]
+[[['*Selection*]] [ ] [ ] [ ] [ ] [ ] [ ] [ ]]
+[[`J T::find(const domain_type&)`] [ ] [2] [2] [2] [2] [2] [2]]
+[[`codomain_type& operator[] (const domain_type&)`][ ] [ ] [??] [ ] [1] [ ] [1]]
+[[`codomain_type operator() (const domain_type&)const`][ ][ ] [1?] [ ] [1?] [ ] [ ]]
 [[['*Addition*]] [interval][interval\nsets][interval\nmaps][itl::set][itl::map][std::set][std::map]]
 [[`T& T::add(const P&)`] [ ] [__ei] [__bp] [__e] [__b] [ ] [ ]]
 [[`T& operator +=( T&, const P&)`] [ ] [__eiS] [__bpM] [__es] [__bm] [ ] [ ]]
@@ -396,11 +400,11 @@
 [[`T operator | (const T&, const P&)`] [ ] [__eiS] [__bpM] [__es] [__bm] [ ] [JODO test]]
 [[['*Subtraction*]] [ ] [ ] [ ] [ ] [ ] [ ] [ ]]
 [[`T& T::subtract(const P&)`] [ ] [__ei] [__bp] [__e] [__b] [ ] [ ]]
-[[`T& operator -=( T&, const P&)`] [ ] [__eiS] [__bpM] [?__eS] [?__bM] [ ] [ ]]
-[[`T operator - (const T&, const P&)`] [ ] [__eiS] [__bpM] [?__eS] [?__bM] [ ] [ ]]
-[[['*Insertion, erasure*]] [ ] [ ] [ ] [ ] [ ] [ ] [ ]]
-[[`T& T::insert(const P&)`] [ ] [__ei] [__bp] [__e] [__b] [?__e] [?__b]]
-[[`T& T::set(const P&)`] [ ] [__ei?] [__bp?] [__e?] [__b?] [?__e?] [JODO]]
+[[`T& operator -=( T&, const P&)`] [ ] [__eiS] [__bpM] [__es] [__bm] [ ] [ ]]
+[[`T operator - (const T&, const P&)`] [ ] [__eiS] [__bpM] [__es] [__bm] [ ] [JODO test]]
+[[['*Insertion, erasure*]] [interval][interval\nsets][interval\nmaps][itl::set][itl::map][std::set][std::map]]
+[[`V T::insert(const P&)`] [ ] [__ei] [__bp] [__e] [__b] [__e] [__b]]
+[[`T& T::set(const P&)`] [ ] [ ] [__bp?] [ ] [__b?] [ ] [JODO]]
 [[`T& T::erase(const P&)`] [ ] [__eiS][__eiS __bpM][__e] [__b] [?__e] [?__b]]
 [[['*Intersection, symmetric difference*]] [ ] [ ] [ ] [ ] [ ] [ ] [ ]]
 [[`void T::intersect(T&, const P&)const`] [__i] [__eiS][__eiS __bpM][ ] [ ] [ ] [ ]]


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