Context: I use an ArrayCollection object as follows: 1) Number of elements is fixed. 2) Elements are inserted at a given position, based on some order.
Question: Can I set the m开发者_如何学JAVAax size of the ArrayCollection? Will fixing the size improve the performance, as elements keep getting inserted into this collection?
-Thank You
Can I set the max size of the ArrayCollection?
The ArrayCollection is simply a wrapper for an Array object. The Array's size can be set and ArrayCollection cannot addItemAt positions beyond the array's bounds (it will throw an exception). But the array's size can still be increased for example by the ArrayCollection's addItem method. To prevent this you will have to make your own ArrayCollection class.
Will fixing the size improve the performance, as elements keep getting inserted into this collection?
Since the Array object that the ArrayCollection wraps does not support fixed length arrays it seems unlikely there will be an additional performance gain beyond that from not forcing the array to resize.
精彩评论