> I'm wondering how to set the size of an unconstrained array.
Any particular array is constrained. You can write, for instance, a
sort routine that sorts an unconstrained array, but any particular call
will pass it a particular, constrained, array. So the declaration of an
object of unconstrained array type (a String, for instance) will give a
specific size.
> I'm wondering if there is any way to modify the size of an
> array during run-time
You could allocate an array on the heap, then if it needs to be bigger
you can allocate a new, larger, array, copy the contents of the old
array, then deallocate the old one.
> I really don't want to just make a
> large array, and use that, and hope that all my data will
> always fit into this array.
That may in fact be the best way to go, depending on your OS's virtual
memory implementation. If a giant array is made of real memory pages
that only take up RAM when actual data is written into them, then if you
only use the first part, only a few pages of real memory will actually
be allocated. If you add data beyond that, the OS will allocate more
pages of real memory. But the high-index parts you never actually use
will never actually be allocated by the OS.
|