Pregunta

Am looking for an efficient way to initialize a HashMap given that it's keys remain the same for any object created of the class it belongs to.

My current implementation initializes the HashMap everytime a new class object is created.

Thanks!

¿Fue útil?

Solución

You can create a template Map, and use .clone() to generate new instances. You could also create a custom Map implementation that uses a copy-on-write policy to refer to a template "parent" Map.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top