diff --git a/test/algorithms/maximum_gap.cpp b/test/algorithms/maximum_gap.cpp index 551ce0b37..d73e4b04a 100644 --- a/test/algorithms/maximum_gap.cpp +++ b/test/algorithms/maximum_gap.cpp @@ -4,6 +4,7 @@ // Copyright (c) 2015, Oracle and/or its affiliates. // Contributed and/or modified by Menelaos Karavelas, on behalf of Oracle +// Contributed and/or modified by Adam Wulkiewicz, on behalf of Oracle // Licensed under the Boost Software License version 1.0. // http://www.boost.org/users/license.html @@ -20,12 +21,8 @@ #include #include -#include -#include - #include -namespace ba = boost::assign; namespace bg = boost::geometry; class uint_interval @@ -39,11 +36,6 @@ public: , m_right(right) {} - uint_interval(boost::tuple const& tuple) - : m_left(boost::get<0>(tuple)) - , m_right(boost::get<1>(tuple)) - {} - template value_type get() const { @@ -59,6 +51,23 @@ private: unsigned m_left, m_right; }; +struct uint_intervals + : public std::vector +{ + uint_intervals() + {} + + uint_intervals(unsigned left, unsigned right) + { + this->push_back(uint_interval(left, right)); + } + + uint_intervals & operator()(unsigned left, unsigned right) + { + this->push_back(uint_interval(left, right)); + return *this; + } +}; std::ostream& operator<<(std::ostream& os, uint_interval const& interval) { @@ -81,9 +90,10 @@ inline void test_one(std::string const& case_id, gap_type gap = bg::maximum_gap(intervals); std::ostringstream stream; - for (std::vector::const_iterator it = intervals.begin(); - it != intervals.end(); - ++it) + for (typename boost::range_const_iterator::type + it = boost::const_begin(intervals); + it != boost::const_end(intervals); + ++it) { stream << " " << *it; } @@ -104,26 +114,26 @@ inline void test_one(std::string const& case_id, BOOST_AUTO_TEST_CASE( test_maximum_gap ) { - std::vector intervals; + uint_intervals intervals; - intervals = ba::tuple_list_of(3,4)(1,10)(5,11)(20,35)(12,14)(36,40)(39,41)(35,36)(37,37)(50,50)(50,51); + intervals = uint_intervals(3,4)(1,10)(5,11)(20,35)(12,14)(36,40)(39,41)(35,36)(37,37)(50,50)(50,51); test_one("case_01", intervals, 9); - intervals = ba::tuple_list_of(3,4)(1,10)(5,11)(20,35)(52,60)(12,14)(36,40)(39,41)(35,36)(37,37)(55,56); + intervals = uint_intervals(3,4)(1,10)(5,11)(20,35)(52,60)(12,14)(36,40)(39,41)(35,36)(37,37)(55,56); test_one("case_02", intervals, 11); - intervals = ba::tuple_list_of(3,4); + intervals = uint_intervals(3,4); test_one("case_03", intervals, 0); - intervals = ba::tuple_list_of(3,4)(15,15); + intervals = uint_intervals(3,4)(15,15); test_one("case_04", intervals, 11); - intervals = ba::tuple_list_of(3,14)(5,5)(5,6); + intervals = uint_intervals(3,14)(5,5)(5,6); test_one("case_05", intervals, 0); - intervals = ba::tuple_list_of(3,10)(15,15)(15,18)(15,16); + intervals = uint_intervals(3,10)(15,15)(15,18)(15,16); test_one("case_06", intervals, 5); - intervals = ba::tuple_list_of(38,41)(3,10)(15,15)(15,18)(15,16)(20,30)(22,30)(23,30); + intervals = uint_intervals(38,41)(3,10)(15,15)(15,18)(15,16)(20,30)(22,30)(23,30); test_one("case_07", intervals, 8); }