8

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

Community
  • 1
  • 1
Matt Warrick
  • 1,385
  • 1
  • 13
  • 22
  • Probably because such data-structures are quite specialized -- not that there isn't *a* (contrived-existing-somewhere) use-case so much as that it's only for a *very* specific niche not warranting inclusion into the standard library. Including it into the base Java library would also force all [certified] Java run-times to include it, increasing size (bytecode) and code (complexity) -- it's not "free" to make something part of the standard libraries. (There are so many more "common" features I find missing :-/) –  Aug 27 '11 at 22:24

1 Answers1

10

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.

Bozho
  • 588,226
  • 146
  • 1,060
  • 1,140