as Erik says: immutable Point # immutable is the kind of type to use when you want memory to be immediate x::Cdouble y::Cdouble end
a = [Point(0.0, 0.0),Point(0.2,0.3),Point(1.1, 1.3)] sizeof(a) 48 On Thursday, February 25, 2016 at 4:34:20 PM UTC-5, Martin Kuzma wrote: > > I have the the following type defined: > > type Point > x::Cdouble > y::Cdouble > end > Calling sizeof returns 16 as expected. But when I have for example: > > a = [Point(0.0, 0.0),Point(0.2,0.3),Point(1.1, 1.3)] > > sizeof returns *24*. But I expected it to return 3 * 16 = *48*. (It looks > like in the array are stored pointers to Point objects not the objects) > > My problem is that I need to convert Vector{Point} to Vector{Cdouble}. So > i tried: > > tmp1 = pointer(a) > tmp2 = convert(Ptr{Cdouble}, tmp1) > points = pointer_to_array(tmp2, length(a) * 2, true) > But the output is not what I want it to be. It is an array of some random > values. Is there a way to make this work? All i need is basically to > convert Vector{Point} to Vector{Cdouble} without the need of creating a new > array. > > > > > > >