Let's say I've got a list of Strings (simplification)
fullList = {a,b,c,d,a,d,c,b}
and I want to find couples like
couplesList = {{a,a},{b,b}, ...}
The way I'm approaching this problem at the moment is
- Get first element
- Use guava predicate to find proper object
- What now?
I'm ending up having 2 objects {a,a} but I can't remove them from fullList
because I'm not using an "iterator" style of iterating (because I'm using Guava predicate it wouldn't work anyway - since I don't have iterator pointer to element that was find by Itarables.find(...)
function).
I want to do it in "efficient" way as well, so I want to avoid multiple nested loops etc.
Any ideas how to approach this problem more correctly/efficient way ? I'm bit stuck.