Re: boolean sequence

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

Tone Skoda wrote:

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

Agreed.

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

find_byte_forward() is somewhat similar to Euphoria's built-in find().
It returns the number of the lowest order byte in the sequence, that is
equal to a given value (or returns -1, if that value is not found).
It returns a different index than find(), though. Example:

sequence s
s = {#00000000, #00000027}
? find(#27, s)                   --> 2nd element of s
? find_byte_forward(s, #27)      --> 5th byte in s


E.g. for use with put_byte(), of course 5 is the correct index, not 2.

Uhhhh... I just realized that I mixed up the order of the arguments. getlost
   find_byte_forward(#27, s)
would be better, I think.

Also, since the whole thing is 1-based now, 0 could beused instead of -1,
in order to indicate, that find_byte_... didn't find the given value.
What do you think?

> if you are planning to release a lib out of these functions,

Maybe...
I'll only do so, if I find some nice, self-explanatory function names,
and when I have the time to write a sufficient documentation.

> 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

Yes, I also thought of that.

> 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})

Great idea!

> 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.

100% agreed.
Maybe I should add pack/unpack functions? Then the user can "unpack" a
byte array to a normal sequence, use any existing function that (s)he
wants, and then "re-pack" the normal sequence, to get again a byte
array.

[snipped old text]

Regards,
   Juergen

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

Search



Quick Links

User menu

Not signed in.

Misc Menu