Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r60919 - in trunk/boost: detail graph
From: jewillco_at_[hidden]
Date: 2010-03-29 13:30:53


Author: jewillco
Date: 2010-03-29 13:30:52 EDT (Mon, 29 Mar 2010)
New Revision: 60919
URL: http://svn.boost.org/trac/boost/changeset/60919

Log:
Removed unused iota function, changed the two uses of any_if to use find_if instead, using Boost.Range for the other algorithms to avoid redundancies
Text files modified:
   trunk/boost/detail/algorithm.hpp | 166 ---------------------------------------
   trunk/boost/graph/graph_test.hpp | 8 +
   2 files changed, 8 insertions(+), 166 deletions(-)

Modified: trunk/boost/detail/algorithm.hpp
==============================================================================
--- trunk/boost/detail/algorithm.hpp (original)
+++ trunk/boost/detail/algorithm.hpp 2010-03-29 13:30:52 EDT (Mon, 29 Mar 2010)
@@ -40,117 +40,12 @@
 
 #include <algorithm>
 #include <vector>
+#include <boost/range.hpp>
+#include <boost/range/algorithm.hpp>
+#include <boost/range/algorithm_ext.hpp>
 
 namespace boost {
 
- template <typename Iter1, typename Iter2>
- Iter1 begin(const std::pair<Iter1, Iter2>& p) { return p.first; }
-
- template <typename Iter1, typename Iter2>
- Iter2 end(const std::pair<Iter1, Iter2>& p) { return p.second; }
-
- template <typename Iter1, typename Iter2>
- typename boost::detail::iterator_traits<Iter1>::difference_type
- size(const std::pair<Iter1, Iter2>& p) {
- return std::distance(p.first, p.second);
- }
-
-#if 0
- // These seem to interfere with the std::pair overloads :(
- template <typename Container>
- typename Container::iterator
- begin(Container& c) { return c.begin(); }
-
- template <typename Container>
- typename Container::const_iterator
- begin(const Container& c) { return c.begin(); }
-
- template <typename Container>
- typename Container::iterator
- end(Container& c) { return c.end(); }
-
- template <typename Container>
- typename Container::const_iterator
- end(const Container& c) { return c.end(); }
-
- template <typename Container>
- typename Container::size_type
- size(const Container& c) { return c.size(); }
-#else
- template <typename T>
- typename std::vector<T>::iterator
- begin(std::vector<T>& c) { return c.begin(); }
-
- template <typename T>
- typename std::vector<T>::const_iterator
- begin(const std::vector<T>& c) { return c.begin(); }
-
- template <typename T>
- typename std::vector<T>::iterator
- end(std::vector<T>& c) { return c.end(); }
-
- template <typename T>
- typename std::vector<T>::const_iterator
- end(const std::vector<T>& c) { return c.end(); }
-
- template <typename T>
- typename std::vector<T>::size_type
- size(const std::vector<T>& c) { return c.size(); }
-#endif
-
- template <class ForwardIterator, class T>
- void iota(ForwardIterator first, ForwardIterator last, T value)
- {
- for (; first != last; ++first, ++value)
- *first = value;
- }
- template <typename Container, typename T>
- void iota(Container& c, const T& value)
- {
- iota(begin(c), end(c), value);
- }
-
- // Also do version with 2nd container?
- template <typename Container, typename OutIter>
- OutIter copy(const Container& c, OutIter result) {
- return std::copy(begin(c), end(c), result);
- }
-
- template <typename Container1, typename Container2>
- bool equal(const Container1& c1, const Container2& c2)
- {
- if (size(c1) != size(c2))
- return false;
- return std::equal(begin(c1), end(c1), begin(c2));
- }
-
- template <typename Container>
- void sort(Container& c) { std::sort(begin(c), end(c)); }
-
- template <typename Container, typename Predicate>
- void sort(Container& c, const Predicate& p) {
- std::sort(begin(c), end(c), p);
- }
-
- template <typename Container>
- void stable_sort(Container& c) { std::stable_sort(begin(c), end(c)); }
-
- template <typename Container, typename Predicate>
- void stable_sort(Container& c, const Predicate& p) {
- std::stable_sort(begin(c), end(c), p);
- }
-
- template <typename InputIterator, typename Predicate>
- bool any_if(InputIterator first, InputIterator last, Predicate p)
- {
- return std::find_if(first, last, p) != last;
- }
- template <typename Container, typename Predicate>
- bool any_if(const Container& c, Predicate p)
- {
- return any_if(begin(c), end(c), p);
- }
-
   template <typename InputIterator, typename T>
   bool container_contains(InputIterator first, InputIterator last, T value)
   {
@@ -162,61 +57,6 @@
     return container_contains(begin(c), end(c), value);
   }
 
- template <typename Container, typename T>
- std::size_t count(const Container& c, const T& value)
- {
- return std::count(begin(c), end(c), value);
- }
-
- template <typename Container, typename Predicate>
- std::size_t count_if(const Container& c, Predicate p)
- {
- return std::count_if(begin(c), end(c), p);
- }
-
- template <typename ForwardIterator>
- bool is_sorted(ForwardIterator first, ForwardIterator last)
- {
- if (first == last)
- return true;
-
- ForwardIterator next = first;
- for (++next; next != last; first = next, ++next) {
- if (*next < *first)
- return false;
- }
-
- return true;
- }
-
- template <typename ForwardIterator, typename StrictWeakOrdering>
- bool is_sorted(ForwardIterator first, ForwardIterator last,
- StrictWeakOrdering comp)
- {
- if (first == last)
- return true;
-
- ForwardIterator next = first;
- for (++next; next != last; first = next, ++next) {
- if (comp(*next, *first))
- return false;
- }
-
- return true;
- }
-
- template <typename Container>
- bool is_sorted(const Container& c)
- {
- return is_sorted(begin(c), end(c));
- }
-
- template <typename Container, typename StrictWeakOrdering>
- bool is_sorted(const Container& c, StrictWeakOrdering comp)
- {
- return is_sorted(begin(c), end(c), comp);
- }
-
 } // namespace boost
 
 #endif // BOOST_ALGORITHM_HPP

Modified: trunk/boost/graph/graph_test.hpp
==============================================================================
--- trunk/boost/graph/graph_test.hpp (original)
+++ trunk/boost/graph/graph_test.hpp 2010-03-29 13:30:52 EDT (Mon, 29 Mar 2010)
@@ -17,6 +17,8 @@
 #include <boost/graph/isomorphism.hpp>
 #include <boost/graph/copy.hpp>
 #include <boost/graph/graph_utility.hpp> // for connects
+#include <boost/range.hpp>
+#include <boost/range/algorithm/find_if.hpp>
 
 
 // UNDER CONSTRUCTION
@@ -171,7 +173,7 @@
       BOOST_CHECK(m == num_edges(g));
       for (; p.first != p.second; ++p.first) {
         edge_t e = *p.first;
- BOOST_CHECK(any_if(edge_set, connects(source(e, g), target(e, g), g)));
+ BOOST_CHECK(find_if(edge_set, connects(source(e, g), target(e, g), g)) != end(edge_set));
         BOOST_CHECK(container_contains(vertex_set, source(e, g)) == true);
         BOOST_CHECK(container_contains(vertex_set, target(e, g)) == true);
       }
@@ -196,8 +198,8 @@
         for (k = vertex_set.begin(); k != vertex_set.end(); ++k) {
           p = edge(*j, *k, g);
           if (p.second == true)
- BOOST_CHECK(any_if(edge_set,
- connects(source(p.first, g), target(p.first, g), g)) == true);
+ BOOST_CHECK(find_if(edge_set,
+ connects(source(p.first, g), target(p.first, g), g)) != end(edge_set));
         }
     }
 


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