java - Remove duplicated key Map.Entry from a List -
i have list
of map.entry
, in roder have list of pairs.
in list
, inserting pairs key long
value representing unix epoch, , value string
text:
arraylist<map.entry<long, string>> events = new arraylist<map.entry<long, string>>(); events.add(new map.entry<long, string>(140000000, "test event"));
i want remove map.entry duplicated key, each unix epoch have associated string
. fancy way of doing without iterating whole list manually?
bonus if string
value concat of string
values same key.
use hashmap - allows single entry per key, overwrite. can mapentries out of map using map.entryset. works if keys same values different.
just putting entries set work if key , value pairs same, i.e. identical entries, opposed having same key. behaviour of mapentry.equals() understand this.
Comments
Post a Comment