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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top