java - How to get most recent 100 data from a Map? -


i have map of long , string - map stores timestamp key , value data.

map<long, string> eventtimestampholder = new hashmap<long, string>(); 

now want 100 recent data above map looking @ timestamp part of key , keep on adding data in list of string. in general populate 100 recent data in list.

what best way this? can use treemap here , sort keys basis on timestamp properly?

in general timestamp going - 1417686422238 , in milliseconds

in case mean "recent" added, can try linkedhashmap maintain order of insertion. can iterate on first 100 items.

you can iterate on map this:

for(long key : eventtimestampholder.keyset()) {     string value = eventtimestampholder.get(key); } 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -