SetMaker / ListMaker

80 views
Skip to first unread message

Nanda Firdausi

unread,
Nov 16, 2009, 4:03:55 AM11/16/09
to google-colle...@googlegroups.com
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
http://satukubik.com

Kevin Bourrillion

unread,
Nov 16, 2009, 10:18:27 AM11/16/09
to Nanda Firdausi, google-colle...@googlegroups.com
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 com.google.common.collect.Sets.newSetFromMap() (jdk 5).


--
Google Collections Library - users list
http://groups.google.com/group/google-collections-dev?hl=en
 
To unsubscribe, send email to:
google-collections...@googlegroups.com



--
Kevin Bourrillion @ Google
internal:  http://go/javalibraries
external: guava-libraries.googlecode.com

Reply all
Reply to author
Forward
0 new messages