English Français Deutsch

inc/bitmpap.php

swBitmap provides a memory-effective way to store an array of booleans using only one bit per array. The bit-array is n-based. You cannot set the bit 0.

Note that 8 bit are in a byte. If the length is not a multiple of 8, there are 1-7 bits at the end that are undefined. (To be taken care of)

Objets

swBitmap extends swRecord

length number of bits
map bitmap
state (obsolete?)
touched bitmap has been changed since open
maphex human-readable representation of bitmap to save in textfile

init($l, $default=false) creates a map of the length $l and fills it with true or false based on $default

redim($l, $default=false) grows a bitmap to the new length.

setbit($n) sets the nth bit to true.

unsetbit($n) sets the nth bit to false.

getbit($n) returns the value of the nth bit.

duplicate() returns a copy of the bitmap.

andop($bitmap) returns a new bitmap with the value C = A & B.

orop($bitmap) returns a new bitmap with the value C = A | B.

notop($bitmap) returns an inverted copy of the bitmap.

dump() returns the bitmap as string of 0 and 1, grouped by 8.

countbits() returns the number of true bits in the bitmap.

toarray() returns an array of all true bits.

hexit() creates maphex from map. Maphex is to save. It is basically hex from bitmap using 2 bytes for 256 values instead of one byte. The string is then compressed because many consecutives bits are 0 or 1:

dehexit() creates map from maphex.

File structure inc folder