I want to use the fastest possible method to match a String with a String in List.
Im iterating trough a list to match productname and set price for that product.
Im trying to match every 400 000 items by name in another list where i could find the price, that list also contains 400 000 items.
Doing a "contains()" on String to match 400 000 items 400 000 times takes a long time to finish. I did also try startsWith() as i dont search by substring, im using the String because there is for sure a full match in the second list. It just has to be a faster way to find a match in the inner for loop to get the price?
ProductData t = null;
for (int i = 0; i < ParseCSV.products.size(); i++) { // List of 400K+ items
t = ParseCSV.products.get(i);
for (int j = 0; j < ParseCSVprice.productPrice.size(); j++) { // another List of 400K+ items
if (ParseCSVprice.productPrice.get(i).getpairID()
.contains(t.pairID)) {
t.price = ParseCSVprice.productPrice.get(i).getPrice();
}
}