开发者

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

开发者 https://www.devze.com 2023-03-31 00:50 出处:网络
This question already has answers here: W开发者_如何学Pythonhy does exist WeakHashMap, but absent WeakSet?
This question already has answers here: W开发者_如何学Pythonhy does exist WeakHashMap, but absent WeakSet? (2 answers) Closed 5 years ago.

... 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?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号