TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Forum View

Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Tom Moran <[log in to unmask]>
Reply To:
Tom Moran <[log in to unmask]>
Date:
Sat, 23 Dec 2000 15:20:35 -0800
Content-Type:
text/plain
Parts/Attachments:
text/plain (24 lines)
> 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.

ATOM RSS1 RSS2