I have some custom ranges as below:
Range A 3-6
Range B 6-9
Range C 10-11
Range D 12-15
Range E 16-99 (All the ranges are inclusive)
I have a List in a sorted order (low to high). The ranges should be enabled if there is at least one number from the list that fits in the respective ranges
To solve this i have to iterate the list and check whether at least one number fits in the range:
for(Integer a:list) {
if (new Range(3, 6).contains(a.intValue())) {
available = true; //(for respective range)
break;
}
}
comparing each and every value of list to enable a range seems to be a performance to me. Is there any best solution for this??
I am having a Range object with following attributes
private String name;
private int min;
private int max;
private boolean available;
3&6 in above snippet is min & max of Range A