From 242a2016d6ed911745b417e96b2b81c5e95fb6c1 Mon Sep 17 00:00:00 2001 From: Mattrixwv Date: Sun, 18 Aug 2019 11:53:05 -0400 Subject: [PATCH] Changed isFound to use functions in the STL --- Algorithms.hpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Algorithms.hpp b/Algorithms.hpp index a0d869c..a536251 100644 --- a/Algorithms.hpp +++ b/Algorithms.hpp @@ -260,12 +260,13 @@ T getProduct(const std::vector& ary){ //This is a function that searches a vecter for an element. Returns true if they key is found in list template bool isFound(std::vector ary, T key){ - for(int cnt = 0;cnt < ary.size();++cnt){ - if(ary.at(cnt) == key){ - return true; - } + std::vector::iterator location = std::find(ary.begin(), ary.end(), key); + if(location == ary.end()){ + return false; + } + else{ + return true; } - return false; } //This is a function that creates all permutations of a string and returns a vector of those permutations.