java - How to remove elements from collection while iterating without iterator -


let's i've got list of strings (simplification)

fulllist = {a,b,c,d,a,d,c,b}

and want find couples like

coupleslist = {{a,a},{b,b}, ...}

the way i'm approaching problem @ moment is

  1. get first element
  2. use guava predicate find proper object
  3. what now?

i'm ending having 2 objects {a,a} can't remove them fulllist because i'm not using "iterator" style of iterating (because i'm using guava predicate wouldn't work anyway - since don't have iterator pointer element find itarables.find(...) function).

i want in "efficient" way well, want avoid multiple nested loops etc.

any ideas how approach problem more correctly/efficient way ? i'm bit stuck.

i create frequency count each of elements. in guava terms multiset. can create collection of pairs, , collection of singles. can done 1 pass of original list , 1 pass of frequency count map. i.e. o(n)


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -