Thanks Stefan!
I thought it would be like declaring a struct array in c/c++ i.e. something
like ExampleEvent events[2][1000]; Then set each field in the events array
as I encounter the required value in my algo: e.g. events[1][1].fld1 =
"ABC"; events[1][1].fld2 = 123; etc
How do I access elements in the events Vector since ndims(events) = 1? I
don't see anything in the docs about indexing into a preallocated Vector
data structure. I see methods like push! splice! etc but not anything that
will let me use the elements of my preallocation on the fly.
On Thursday, July 21, 2016 at 3:21:54 PM UTC-4, Stefan Karpinski wrote:
>
> It's a little unclear what you want to do that you can't figure out how to
> accomplish. You can allocate an uninitialized vector of ExampleEvent
> objects:
>
> julia> type ExampleEvent
> fld1::ASCIIString
> fld2::Int16
> fld3::Int64
> fld4::Int64
> fld5::Int64
> fld6::Int64
> fld7::Int64
> end
>
> julia> events = Vector{ExampleEvent}(1000)
> 1000-element Array{ExampleEvent,1}:
> #undef
> #undef
> #undef
> ⋮
> #undef
> #undef
> #undef
>
>
>
>
> On Thu, Jul 21, 2016 at 2:51 PM, <[email protected] <javascript:>> wrote:
>
>>
>> Hi
>>
>> I was working on processing large data sets & historically I've used
>> structs in C++ & other languages for this type of task. I attempted to use
>> a Composite Type in Julia & preallocate a large array before filling it
>> w/values as my algo processes the data.
>>
>> My example was:
>>
>> type ExampleEvent
>>
>> fld1::ASCIIString
>> fld2::Int16
>> fld3::Int64
>> fld4::Int64
>> fld5::Int64
>> fld6::Int64
>> fld7::Int64
>>
>> end
>>
>> I googled around & from what I found, & all the docs examples I tried
>> out, there isn't an obvious way to declare an array of composite type
>> without having to do some work arounds.
>>
>> I liked the language in several other respects but it seems to be missing
>> helpful tools to make the programmer's life easy. Am I missing something?
>> If not, why is a data structure like this not easily available?
>>
>> thanks in advance
>>
>> best,
>> A
>>
>
>