How can I get items by conditions? for example:
public class Candy {
    int SugarCantains = 0;
    Candy(int sugarcontains){
        this.SugarCantains = sugarcontains;
    }
    static List<Candy> candies = new ArrayList<>();
    {
        for (int I = 0; I < 9; I++){
            candies.add(new Candy(I))
        }
    }
}
And how can I get candies that SugarContains is less that 5 in list candies?
candies.getByConditions((SugarContains < 5));
I know I can use for loop:
List<Candy> LowSugarCandies = new ArrayList<>();
for (Candy c: candies){
    if (c.SugarContains < 5){
        LowSugarCandies.add(c);
    }
}
but it's too slow, are there any faster way to do that?
And I have same problem in python, how can I do that in python?
