A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
List and Set in one
Joined: Oct 17, 2006
May 11, 2009 10:14:20
What do you usually use when you need a collection that is unique (like a Set) but has indexes (like a List)?
Joined: Mar 22, 2005
May 11, 2009 10:21:57
Maybe write a subclass of
that enforces the uniqueness of elements. There are probably ready-made classes like that out there.
Ping & DNS
- my free Android networking tools app
Joined: Nov 22, 2002
May 11, 2009 11:17:09
Fahd Shariff<br />"Let the code do the talking"
Author and ninkuma
Joined: Jan 10, 2002
May 11, 2009 11:21:46
Fahd Shariff wrote:
will retain the iteration order, it is not indexable. That would have to be added.
I'd still go with Ulf's approach as it's easier to add uniqueness to a List than index-ability to a Set.
Asking smart questions
Books by Bear
I agree. Here's the link:
subject: List and Set in one
How to sort HashSet containing custom Objects...?
JComboBox: Telling difference if model update or actual select.
Error with creation of data source
Intersection of two lists
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014