Added isFound function

This commit is contained in:
2019-03-17 19:01:44 -04:00
parent 906db6815f
commit caebee7e6d
3 changed files with 157 additions and 1 deletions

Binary file not shown.

View File

@@ -25,7 +25,6 @@ Copyright (C) 2019 Matthew Ellison
package mattrixwv;
import java.util.Arrays;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collections;
@@ -730,4 +729,37 @@ public class Algorithms{
//Return the product of all elements
return product;
}
public static Boolean isFound(ArrayList<Integer> ary, Integer key){
//Look through every element in the array, looing for the key element
for(Integer num : ary){
//If there is an element in the array that is the same as key return true
if(num == key){
return true;
}
}
//If you made it to the end of the array without finding a match return false because the element was not found
return false;
}
public static Boolean isLongFound(ArrayList<Long> ary, Long key){
//Look through every element in the array, looing for the key element
for(Long num : ary){
//If there is an element in the array that is the same as key return true
if(num == key){
return true;
}
}
//If you made it to the end of the array without finding a match return false because the element was not found
return false;
}
public static Boolean isBigFound(ArrayList<BigInteger> ary, BigInteger key){
//Look through every element in the array, looing for the key element
for(BigInteger num : ary){
//If there is an element in the array that is the same as key return true
if(num == key){
return true;
}
}
//If you made it to the end of the array without finding a match return false because the element was not found
return false;
}
}