Large bit-strings

Yoshiki.Ohshima at acm.org Yoshiki.Ohshima at acm.org
Tue Jul 29 23:34:18 UTC 2003


  Jens,

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

  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



More information about the Squeak-dev mailing list