Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why there is no WeakList and WeakSet implementation in Java? [duplicate]

... at least not "official".

You can easily google two or three "WeakList" example implementation and for "WeakSet" one very good can be found in NetBeans Platform API sources.

I read similar question placed here asking for WeakSet. Answers were "there is no usecase for WeakSet". If it will be like this why these unofficial implementations exist?

like image 262
Matt Avatar asked Aug 27 '11 22:08

Matt


1 Answers

Perhaps you can get one by using Collections.newSetFromMap(new WeakHashMap()). Many collections don't exist as public classes (if they are not-so-important), but can be obtained by the Collections factory methods.

like image 84
Bozho Avatar answered Nov 12 '22 18:11

Bozho