Re: boolean sequence

new topic     » goto parent     » topic index » view thread      » older message » newer message

i like set #1 much more more because it's simpler for the user of the lib.

i'm not sure what  find_byte_... functions do?

if you are planning to release a lib out of these functions, 
for the simplicity of the lib for the user it would be good if you would add
these 2 functions (i couldn't think of better function names):

1. bs_new ()
function to create new sequence which holds data. so for bitset you could use
this code:
sequence_of_int_32bit pattern
pattern = bs_new (100)
for i = 1 to 100 do
    pattern = bs_set (pattern, i)
end for


2. bs_newassign ()
function to create an array with initial values set and proper size auto-made:
sequence_of_int_32bit pattern
pattern = bs_newassign ({1, 0, 0, 1, 0, 1, 0})




this lib will be useful because if i have sequence with strings, i will be able
to use byte-set and have sequence that is 4x smaller than regular eu sequence
with strings. that's pretty good if your program uses a lot of RAM. and speed for
setting and getting members in these arrays shouldnt be a problem. the biggest
"problem" will be that code will be a bit uglier and complicated and existing
functions cant be used on these arrays.
so main use of this lib is saving RAM.


Juergen Luethje wrote:
> 
> Tone =A6koda wrote:
> 
> > can you also add support for char (8 bit) and short (16 bit). i don't
> > know how to handle signed or unsigned numbers for these two types?
> 
> You are welcome.
> 
> Do you want that those routines use 0 as base index like the bit
> routines (AFAIK this is standard for manipulating bits), or that they
> use 1 as base index like standard Eu sequences?
> 
> This signed/unsigned thing actually makes it a little more complex than
> the bit routines. For instance concerning bytes, ATM I'm thinking of two
> different possible sets of functions.
> One possibility is, to write one separate function for any purpose, this
> would result in something like the 7 functions in "set #1".
> The other possibility that I'm thinking of is, to write just the
> functions that handle unsigned values, and additionally provide two
> conversion functions, like in "set #2".
> 
> ------------------------------------------------------------------------
> -- set #1
> 
> function put_byte()
>    -- It doesn't matter, whether or not the byte to put is signed or unsign=
> ed.
> function get_byte_u()
>    -- return an *unsigned byte*
> function get_byte_s()
>    -- return a *signed byte*
> 
> [The 3 functions above are very similar to poke(), peeku(), and peeks()]
> 
> function find_byte_forward_u()
>    -- find an *unsigned byte*
> function find_byte_forward_s()
>    -- find a *signed byte*
> function find_byte_reverse_u()
>    -- find an *unsigned byte*
> function find_byte_reverse_s()
>    -- find an *signed byte*
> 
> ------------------------------------------------------------------------
> -- set #2
> 
> function put_byte()
>    -- It doesn't matter, whether or not the byte to put is signed or unsign=
> ed.
> 
> function get_byte_u()
>    -- return an *unsigned byte*
> function find_byte_forward_u()
>    -- find an *unsigned byte*
> function find_byte_reverse_u()
>    -- find an *unsigned byte*
> 
> function unsigned_byte()
>    -- convert a signed byte to unsigned
> function signed_byte()
>    -- convert a unsigned byte to signed
> 
> ------------------------------------------------------------------------
> 
> I hope I was able to express myself clearly. Please tell me, what you
> want.
> 
> Regards,
>    Juergen
> 
>

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu