I saw that in some places that the data structure TLongArrayList is used instead of an array of long primitives. I wish to ask what is the benefit to use TLongArrayList over long[] ?
The TLongArrayList
class from the GNU Trove project implements a dynamic array data structure (wikipedia) for elements that are primitive long
values.
The benefit of "dynamic array" over the native fixed-sized long[]
array is that you can add and remove elements, including in the middle, and that the data structure automatically expands to meet usage. In comparison, when you create an array you have to decide the size at the time of creation, and all the array elements are created at that time. With a fixed sized array, you cannot add or remove elements, only replace existing elements.