I have python background so please allow me have my code in python.
In Java (Android) have an arrayList<customObject>. In each customObject corresponds a boolean (for visibility).
I want to perform operations as more efficient as possible to check the visibility boolean. In python I would create a generator.
Assuming my schema is :
list = [{"item": customObject, "visible": boolean}, {...}, {...}]
visible_matches = [x for x in list if x['visible']]
for match in visible_matches:
dosomething(match)
or an alternative schema:
list = [[ customObject, boolean], [...], [...]]
visible_matches = [x for x in list if x[1]]
How could I perform the same in Java?
arrayList<arrayList<boolean,customObject>> or
arrayList< SimpleEntry<"item",customObject>, SimpleEntry<"visible",boolean> >
look a really dirty solutions to me. Is there any simpler way to achieve this?
[x for x in list if x['visible']]IS a generator.yield).list(x for x in list if x['visible']). Now I see there is no list. It's the difference between () and []. Sorry about that!