java - How Can I iterate this map in reverse direction -
this map iterators remove data based on conditions, want run same map in reverse direction , conditions accordingly.
but couldn't find listiterator
go easily.
how can go ?
also map
implementation using treemap
for(int i=countiteration;i<(countiteration+2);i++) { iterator = imagefilexxsm.entryset().iterator(); while (it.hasnext()) { map.entry pairs = (map.entry)it.next(); if(pairs.getkey().equals(data1.get(i).replace(".png", ".mp3"))) { it.remove(); } } iterator itr = imagefilexxs.entryset().iterator(); while (itr.hasnext()) { map.entry pairsx = (map.entry)itr.next(); if(pairsx.getkey().equals(data1.get(i))) { system.out.println("entry deleted."+pairsx.getkey()); itr.remove(); } } }
treemap
has descendingmap
method (note returns view on original map, not copy it):
//iterate on entry set in reverse order (map.entry<x,y> e : map.descendingmap().entryset()) { x key = e.getkey(); y value = e.getvalue(); }
Comments
Post a Comment