From 90681c67a6c59aacda7d8f673fe0afedbf225f0a Mon Sep 17 00:00:00 2001 From: Magnus Jonsson Date: Thu, 22 Jan 2004 23:23:36 +0000 Subject: [PATCH] *** empty log message *** --- src/policy.cpp | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/src/policy.cpp b/src/policy.cpp index 43323f17c..2451da781 100755 --- a/src/policy.cpp +++ b/src/policy.cpp @@ -65,33 +65,20 @@ namespace using namespace libtorrent; - - // TODO: replace these two functions with std::find_first_of template bool has_intersection(It1 start1, It1 end1, It2 start2, It2 end2) { - for (;start1 != end1; ++start1) - for (;start2 != end2; ++start2) - if (*start1 == *start2) return true; - return false; + return std::find_first_of(start1,end1,start2,end2) != end1; } piece_block find_first_common(const std::deque& queue, const std::vector& busy) { - for (std::deque::const_reverse_iterator i - = queue.rbegin(); - i != queue.rend(); - ++i) - { - for (std::vector::const_iterator j - = busy.begin(); - j != busy.end(); - ++j) - { - if ((*j) == (*i)) return *i; - } - } + std::deque::const_reverse_iterator common_block = + std::find_first_of(queue.rbegin(),queue.rend(),busy.begin(),busy.end()); + + if(common_block!=queue.rend()) + return *common_block; assert(false); return piece_block(-1, -1); }