Alex Rivera | Logout

java TreeSet - don't remove duplicate items

Asked 2011-05-05T09:28:04.060
14

TreeSet removes different items with the same Comprator value. I don't want it be removed. Is there any way to control this? Or use another container class?

Added: OK. It seems I can't use Set. I need insert sorting feature, for performance consideration. Can List do this? Thanks all.

Edit
Report

1 Answer

4

A main purpose of a Set is to not have duplicates. You either don't want a Set or you need a different Comparator.

answered 2011-05-05T09:33:52.013

Your Answer