|
From: Foster B. <fos...@us...> - 2006-02-23 23:29:33
|
Update of /cvsroot/adobe-source/sandbox/adobe-source/adobe In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25760/adobe Modified Files: algorithm.hpp functional.hpp iterator.hpp Log Message: the state of things. We've been working to isolate static_text_t (now called label_t) but it has been slow going because we're trying to wrestle with perfecting the API and what effect that has on other components that were using label_t in a way that isn't in accordance with the new API we're trying to write. As it stands static_disabled_text_m is broken on both platforms, but everything else should be working better. Index: iterator.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/iterator.hpp,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** iterator.hpp 3 Feb 2006 18:33:35 -0000 1.10 --- iterator.hpp 23 Feb 2006 23:28:54 -0000 1.11 *************** *** 312,315 **** --- 312,392 ---- }; + //////////////////////////////////////////////////////////////////////////////////////// + /// + // STEP ITERATOR ADAPTOR + /// \brief step iterator adaptor + /// + /// An adaptor over an existing iterator that changes the step unit + /// (i.e. distance(it,it+1)) by a given predicate. Instead of calling base's + /// operators ++, --, +=, -=, etc. the adaptor is using the passed policy object S_FN + /// for advancing and for computing the distance between iterators. + /// + //////////////////////////////////////////////////////////////////////////////////////// + + template <typename DERIVED, // type of the derived class + typename IT, // Models Iterator + typename S_FN> // A policy object that can compute the distance between two iterators of type IT + // and can advance an iterator of type IT a given number of IT's units + class step_iterator_adaptor : public boost::iterator_adaptor<DERIVED, IT, boost::use_default, boost::use_default, boost::use_default, typename S_FN::difference_type> { + public: + typedef boost::iterator_adaptor<DERIVED, IT, boost::use_default, boost::use_default, boost::use_default, typename S_FN::difference_type> parent_type; + typedef typename std::iterator_traits<IT>::difference_type base_difference_type; + typedef typename S_FN::difference_type difference_type; + typedef typename std::iterator_traits<IT>::reference reference; + + step_iterator_adaptor() {} + step_iterator_adaptor(const IT& it, S_FN step_fn=S_FN()) : parent_type(it), _step_fn(step_fn) {} + + difference_type step() const { return _step_fn.step(); } + + protected: + S_FN _step_fn; + private: + friend class boost::iterator_core_access; + + void increment() { _step_fn.advance(this->base_reference(),1); } + void decrement() { _step_fn.advance(this->base_reference(),-1); } + void advance(base_difference_type d) { _step_fn.advance(this->base_reference(),d); } + difference_type distance_to(const step_iterator_adaptor& it) const { return _step_fn.difference(this->base_reference(),it.base_reference()); } + }; + + // although boost::iterator_adaptor defines these, the default implementation computes distance and compares for zero. + // it is often faster to just apply the relation operator to the base + template <typename D,typename IT,typename S_FN> inline + bool operator>(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) + { + return p1.step()>0 ? p1.base()> p2.base() : p1.base()< p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator<(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) + { + return p1.step()>0 ? p1.base()< p2.base() : p1.base()> p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator>=(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) + { + return p1.step()>0 ? p1.base()>=p2.base() : p1.base()<=p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator<=(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) + { + return p1.step()>0 ? p1.base()<=p2.base() : p1.base()>=p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator==(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) + { + return p1.base()==p2.base(); + } + + template <typename D,typename IT,typename S_FN> inline + bool operator!=(const step_iterator_adaptor<D,IT,S_FN>& p1, const step_iterator_adaptor<D,IT,S_FN>& p2) + { + return p1.base()!=p2.base(); + } + /*************************************************************************************************/ Index: algorithm.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/algorithm.hpp,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** algorithm.hpp 3 Feb 2006 18:33:35 -0000 1.12 --- algorithm.hpp 23 Feb 2006 23:28:54 -0000 1.13 *************** *** 36,39 **** --- 36,40 ---- #include <adobe/algorithm/assign.hpp> #include <adobe/algorithm/reverse.hpp> + #include <adobe/algorithm/copy.hpp> #include <adobe/source/swap.hpp> Index: functional.hpp =================================================================== RCS file: /cvsroot/adobe-source/sandbox/adobe-source/adobe/functional.hpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** functional.hpp 3 Feb 2006 18:33:35 -0000 1.7 --- functional.hpp 23 Feb 2006 23:28:54 -0000 1.8 *************** *** 349,352 **** --- 349,379 ---- /*************************************************************************************************/ + /// \brief plus function object whose arguments may be of different type. + template <typename T1, typename T2> + struct plus_asymmetric : public std::binary_function<T1,T2,T1> + { + T1 operator()(T1 f1, T2 f2) const { + return f1+f2; + } + }; + + /*************************************************************************************************/ + + /// \brief operator++ wrapped in a function object + template <typename T> + struct inc : public std::unary_function<T,T> + { + T operator()(T x) const { return ++x; } + }; + + /*************************************************************************************************/ + + /// \brief operator-- wrapped in a function object + template <typename T> + struct dec : public std::unary_function<T,T> + { + T operator()(T x) const { return --x; } + }; + } // namespace adobe |