packing large array of mixed native types

Discussion in 'Ruby' started by keithroe@gmail.com, Jan 26, 2011.

  1. Guest

    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
     
    , Jan 26, 2011
    #1
    1. Advertising

  2. Hi,

    Am 26.01.2011 21:10, schrieb :
    > 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
     
    Waldemar Dick, Jan 26, 2011
    #2
    1. Advertising

  3. Guest

    I will try this. thanks


    >
    > Why don't you read 4 elements at a time, pack them and write them in an
    > output buffer in a loop?
    >
     
    , Jan 26, 2011
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mike Kamzyuk
    Replies:
    1
    Views:
    1,064
    Victor Bazarov
    Apr 26, 2005
  2. Replies:
    2
    Views:
    324
    Tony Nelson
    Nov 24, 2005
  3. Ketchup
    Replies:
    1
    Views:
    253
    Jan Tielens
    May 25, 2004
  4. Meillo r e t u r n s

    Native cross-compiling (-packing) with GUI

    Meillo r e t u r n s, Dec 23, 2005, in forum: Ruby
    Replies:
    3
    Views:
    122
    Erik Veenstra
    Dec 24, 2005
  5. Replies:
    4
    Views:
    130
    Ned Batchelder
    Nov 13, 2013
Loading...

Share This Page