SetMaker / ListMaker

Skip to first unread message

Nanda Firdausi

Nov 16, 2009, 4:03:55 AM11/16/09
I wonder if there is already a utility class that allow us to create a Set or a List with soft reference/weak reference. I think this will be very useful for example to manage a listeners list. 

If not, what do you think about adding that functionality?

Thank you,
Nanda Firdausi Muhammad

Kevin Bourrillion

Nov 16, 2009, 10:18:27 AM11/16/09
to Nanda Firdausi,
The need for such a Set seems to come up much more often than the List.  My preferred way to handle it would be to simply add a makeSet() method to MapMaker (it would complain if you had already used weakValues() or softValues()), though some find it too odd to use a map maker to make a set, and prefer that we create a separate class called SetMaker.

For now, you can use MapMaker and pass the result to java.util.Collections.newSetFromMap() (jdk 6) or (jdk 5).

Google Collections Library - users list
To unsubscribe, send email to:

Kevin Bourrillion @ Google
internal:  http://go/javalibraries

Reply all
Reply to author
0 new messages