Frage

I want to know if ArrayList represent an Object Pool Pattern. It has an array of Object inside. And all objects of ArrayList can frequently be reused.

War es hilfreich?

Lösung

ArrayList can be a pool container, but it isn't an object pool itself. It needs some algorithmic support to implement caching.
If you, for example, keep track of the head and the tail of the array instead of adding/removing objects to/from the array as it should be, you'll get some kind of manual memory management. Your objects won't be deleted and will probably be reused. Thereat you'll have the right to say that your program uses The object pool pattern.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top