¿Por qué no hay implementación WeakList y WeakSet en Java? [duplicar]

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

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

preguntado el 27 de agosto de 11 a las 22:08

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 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 :-/) -

1 Respuestas

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.

Respondido 28 ago 11, 02:08

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.