I know about SortedSet, but in my case I need something that implements List, and not Set. So is there an implementation out there, in the API or elsewhere?
It shouldn’t be hard to implement myself, but I figured why not ask people here first?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s no Java collection in the standard library to do this.
LinkedHashSet<E>preserves ordering similarly to aList, though, so if you wrap your set in aListwhen you want to use it as aListyou’ll get the semantics you want.Alternatively, the Commons Collections (or
commons-collections4, for the generic version) has aListwhich does what you want already:SetUniqueList/SetUniqueList<E>.