Packing large array of mixed native types

I have an array in the form [ uchar, float, float, float, uchar,
float, float, float, … ]
I know I can pack it like this:
my_array.pack( “CFFFCFFFCFFF…” )
but then I have to create a string with as many elements as the array
I am packing,
which can be quite large. Is there a way to abbreviate this string
(eg, somethign like
my_array.pack( ‘(CFFF)*’ ) ?

Thanks

Hi,

Am 26.01.2011 21:10, schrieb [email protected]:

I have an array in the form [ uchar, float, float, float, uchar,
float, float, float, … ]
I know I can pack it like this:
my_array.pack( “CFFFCFFFCFFF…” )
but then I have to create a string with as many elements as the array
I am packing,
which can be quite large. Is there a way to abbreviate this string
(eg, somethign like
my_array.pack( ‘(CFFF)*’ ) ?

Why don’t you read 4 elements at a time, pack them and write them in an
output buffer in a loop?

Just a thought.

Greetings

Waldemar

I will try this. thanks

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs