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

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -