I need to have an Array of pointers, something like Array<Object*> and i need to preallocate the space for my objects in advance. Since the Array class lacks a setSize call (there is setAllocatedSize but is protected) would be a sensible request to add something like this ? If you pass a null pointer to Array constructor from C array it will not segfault but only allocate and zero the memory for it (without do the copy).
Array (const ElementType* values, int numValues) throw()
: ArrayAllocationBase <ElementType> (juceDefaultArrayGranularity),
numUsed (numValues)
{
this->setAllocatedSize (numValues);
if (values)
memcpy (this->elements, values, numValues * sizeof (ElementType));
else
zeromem (this->elements, numValues * sizeof (ElementType));
}
i know i could use Object** and manage the memory by myself, but i would loose handy shortcuts like indexOf, sort and stuff like that…