Are the entries in a vector of immutable structs stored in place, or
is there always a pointer to the heap?
(Or how can I get Julia to do something equivalent).
I have a question about the interplay between vectors and
If I have a vector of mutable structs, then obviously then each entry
in the vector has an independent life in the heap (since the same
object could be in more than one vector, and if I modify a struct
stored in one vector I can see the modifications in another vector).
On the other hand, if I have a vector of immutable structs (of
well-defined size), then there is no need for a pointer to an
independent object - I can store the contents of the struct in
situ. There is no need for independent allocation on the heap.
The question is: does Julia do this, or is there some way to get the
same effect, so that when I push structured but immutable data onto a
vector, it is written into the vector in the same way as if I were to
push an integer onto a vector of integers, and not linked via a
Motivation is obviously to avoid allocating heap storage every time I
push a structured something onto a vector.