29.12 More about Boolean Lists

In the previous section (see Boolean Lists) we defined a boolean list as a list that has no holes and contains only true and false. There is a special internal representation for boolean lists that needs only 1 bit for every entry. This bit is set if the entry is true and reset if the entry is false. This representation is of course much more compact than the ordinary representation of lists, which needs 32 bits per entry.

Not every boolean list is represented in this compact representation. It would be too much work to test every time a list is changed, whether this list has become a boolean list. This section tells you under which circumstances a boolean list is represented in the compact representation, so you can write your functions in such a way that you make best use of the compact representation.

The results of BlistList, UnionBlist, IntersectionBlist and DifferenceBlist are known to be boolean lists by construction, and thus are represented in the compact representation upon creation.

If an argument of IsBlist, IsSubsetBlist, ListBlist, UnionBlist, IntersectionBlist, DifferenceBlist, UniteBlist, IntersectBlist and SubtractBlist is a list represented in the ordinary representation, it is tested to see if it is in fact a boolean list. If it is not, IsBlist returns false and the other functions signal an error. If it is, the representation of the list is changed to the compact representation.

If you change a boolean list that is represented in the compact representation by assignment (see List Assignment) or Add (see Add) in such a way that the list remains a boolean list it will remain represented in the compact representation. Note that changing a list that is not represented in the compact representation, whether it is a boolean list or not, in such a way that the resulting list becomes a boolean list, will never change the representation of the list.

Previous Up Top
Index

GAP 3.4.4
April 1997