I have two collections
The first contains all the elements.
The second contains the elements that I am interested in from the first collection.
The data is in an alphabetical format:
AAA
AA.12.AA
BBB.234.B1
CC.89
…
The first collection contains around 300.000 records roughly.
Now, if I want to get 10 thousand records from the first collection it is taking up to 40 seconds to find them.
Collection types: firstColl = ArrayList , secondColl = List
Action: I iterate all elements in the firstColl and for every element I check if the secondColl has the element in it.
Just want to know if anyone knows a most performance way to do it by using maybe BigList, Streams,...
CODE:
List<RegionPolygon> regionPolygons = new ArrayList<>();
for (RegionPolygon regionPolygon: result) {
if (regionsArray.contains(regionPolygon.getRegionRef())) {
regionPolygons.add(regionPolygon);
}
}
Note: RegionPolygon has a property which is a String with a very long value (more than 2000 thousand characters easily, although I am not using that property to check if it is the region that I am looking for). Just wanted to say this cause I don't know if this is part of the problem.
result = firstColl
regionsArray = secondColl
Thanks,