A Rec
object has a member variable called tag
which is a String
.
If I have a List
of Rec
s, how could I de-dupe the list based on the tag
member variable?
I just need to make sure that the List
contains only one Rec
with each tag
value.
Something like the following, but I'm not sure what's the best algorithm to keep track counts, etc:
private List<Rec> deDupe(List<Rec> recs) {
for(Rec rec : recs) {
// How to check whether rec.tag exists in another Rec in this List
// and delete any duplicates from the List before returning it to
// the calling method?
}
return recs;
}