SofaDoc

SofaDoc Map Usage

inc/bitmap.php

Contains the swBitmap class to manipulate and store boolean arrays.
Bitmaps are central for indices (indexedbitmap, currentbitmap) and filter functions.
swBitmap provides a memory-effective way to store an array of booleans using only one bit per array.

Classes

swBitmap extends swPersistance

Provides a class to manipulate and store boolean arrays.
The bit-array is 0-based.
NB: There are 8 bit are in a byte. If the length is not a multiple of 8, the bits after length are unefined.

Methods

init($l,$default=false)
Creates the bitmap of length l, filled with default value.
redim($l,$default=false)
Makes the bitmap longer (can only grow), filled with default value.
hexit()
Converts $map to to $maphex and sets $map to empty string (both cannot coexist).
dehexit()
Converts $maphex to to $map and sets $maphex to empty string (both cannot coexist).
save()
open()
setbit($n)
Sets the nth bit to true. If n is bigger than or equal to length, the bitmap will be resized with default value.
unsetbit($n)
Sets the nth bit to false. If n is bigger than or equal to length, the bitmap will be resized with default value.
getbit($n)
Sets the nth bit to false. If n is bigger than or equal to length, the default value will be returned.
duplicate()
Creates a real copy.
andop($bitmap)
Returns a new bitmap with the value C = A AND B.
orop($bitmap)
Returns a new bitmap with the value C = A OR B.
notop()
Returns a new bitmap with the value B = NOT A.
dump()
Returns a readable bitmap, grouped by 8 bits.
countbits()
Returns the number of bits that are true.
toarray()
Returns an array of all true bits.

Properties

$length
Number of bits
$touched
Bitmap has been modified since open
$map
Binary bitmap data
$maphex
Human readable bitmap data
$compressionmode
If set, consecutive values in hex data are further compressed (letters g, h, i, j for 0, p, q, r, s for 1)
$default
Default value if setbit makes the bitmap longer

Functions

bitmapUnitTest()

Used elements

Classes

swBitmap

Functions

bitmapUnitTest

Variables

$bitmap, $bitmask, $byte, $bytes, $default, $dump, $list, $list2, $oldlength, $result, $xormap

Short variables: $b1, $b2, $b3, $bit, $c, $ch, $i, $j, $l, $mod, $n, $r, $s, $t, $v

Features

array, math, misc, str, string, variable

Tokens

T_AMPERSAND_FOLLOWED_BY_VAR_OR_VARARG