Remove Duplicates from List of HashMap Entries
Posted
by HonorGod
on Stack Overflow
See other posts from Stack Overflow
or by HonorGod
Published on 2010-02-03T21:09:04Z
Indexed on
2010/03/31
18:03 UTC
Read the original article
Hit count: 418
java
|collections
I have a List<HashMap<String,Object>> which represents a database where each list record is a database row.
I have 10 columns in my database. There are several rows where the values of 2 particular columns are equals. I need to remove the duplicates from the list after the list is updated with all the rows from database.
What is the efficient way?
FYI - I am not able to do distinct while querying the database, because the GroupName is added at a later stage to the Map after the database is loaded. And since Id column is not primary key, once you add GroupName to the Map. You will have duplicates based on Id + GroupName combination!
Hope my question makes sense. Let me know if we need more clarification.
© Stack Overflow or respective owner