Large bit-strings

Jens Pall jens at axonspace.com
Wed Jul 30 22:19:01 UTC 2003


> > Is there a way to work with very large bit-strings (50k - 100k bits) in
> > Squeak? I could use a collection but I imagine that's a bit inefficient
> > memory vise.
> > Some basic operations I want to be able to do is to cut out a bit
sequences
> > and convert it to a number and roll the string back and forth.
>
>   This is interesting problem...  It depends on what you want to do,
> but one-bit depth Forms and various BitBlt operations could be used.
> You can shift, clip, invert, xor-ing, etc., etc. the bits.

Yes, that could work (hadn't thought of that - thanks :)

>
>   With a very little hack (if not there is a such thing already), you
> should be able to convert Bitmap from/to LargeIntegers.  A
> first-approximation would be to add a method to LargePositiveInteger
> something like:
>
> fromByteArray: aByteArray
>     | inst |
>     inst _ self new: aByteArray size.
>     inst replaceFrom: 1 to: inst size with: aByteArray startingAt: 1.
>     ^ inst.
>
> Then the following examples would work:
>
>   "cut out example:"
>   source _ Form extent: 51200 at 1 depth: 1.
>   result _ source copy: (10240 at 0 extent: 10240 at 1).
>
>   "convert to number:"
>   integer _ LargePositiveInteger fromByteArray: (result bits asByteArray).
>
>   Convert back to integer, and optimizing #fromByteArray is left for
> readers^^;
>
> -- Yoshiki

Well, my Smalltalk knowledge is a bit slim at this time so I really can't
comment on your code, but I will try and figure it out (it looks pretty
simple).

Thanks,
Jens



More information about the Squeak-dev mailing list