Array lacks setSize or something


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));

            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…


You could use insertMultiple() to do this, couldn’t you?


sure thanx !

must double check the docs before posting… it’s the second time i oversee something obvious !