1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
|
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<!-- %% -->
<!-- %A blist.xml GAP documentation Martin Schönert -->
<!-- %% -->
<!-- %% -->
<!-- %Y (C) 1998 School Math and Comp. Sci., University of St Andrews, Scotland -->
<!-- %Y Copyright (C) 2002 The GAP Group -->
<!-- %% -->
<Chapter Label="Boolean Lists">
<Heading>Boolean Lists</Heading>
This chapter describes boolean lists.
A <E>boolean list</E> is a list that has no holes and contains only
the boolean values <K>true</K> and <K>false</K>
(see Chapter <Ref Chap="Booleans"/>).
In function names we call boolean lists <E>blists</E> for brevity.
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="sect:IsBlist">
<Heading>IsBlist (Filter)</Heading>
<#Include Label="IsBlist">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Boolean Lists Representing Subsets">
<Heading>Boolean Lists Representing Subsets</Heading>
<#Include Label="BlistList">
<#Include Label="ListBlist">
<#Include Label="SizeBlist">
<#Include Label="IsSubsetBlist">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Set Operations via Boolean Lists">
<Heading>Set Operations via Boolean Lists</Heading>
<#Include Label="UnionBlist">
<#Include Label="IntersectionBlist">
<#Include Label="DifferenceBlist">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="Function that Modify Boolean Lists">
<Heading>Function that Modify Boolean Lists</Heading>
<#Include Label="UniteBlist">
<#Include Label="UniteBlistList">
<#Include Label="IntersectBlist">
<#Include Label="SubtractBlist">
<#Include Label="MeetBlist">
<#Include Label="FlipBlist">
<#Include Label="SetAllBlist">
<#Include Label="ClearAllBlist">
</Section>
<!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
<Section Label="More about Boolean Lists">
<Heading>More about Boolean Lists</Heading>
We defined a boolean list as a list that has no holes and contains only
<K>true</K> and <K>false</K>.
There is a special internal representation for boolean lists that needs
only 1 bit for each entry.
This bit is set if the entry is <K>true</K> and reset if the entry is
<K>false</K>.
This representation is of course much more compact than the ordinary
representation of lists, which needs 32 or 64 bits per entry.
<P/>
<!-- %T Add a note about internal representation of plain lists (preferably in -->
<!-- %T the chapter <Q>Lists</Q>), -->
<!-- %T in order to allow a user to estimate the space needed for -->
<!-- %T computations with lists; -->
<!-- %T then add cross-references from and to the other available list -->
<!-- %T representations! -->
<P/>
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.
<P/>
If a dense list containing only <K>true</K> and <K>false</K> is read, it
is stored in the compact representation. Furthermore,
the results of <Ref Func="BlistList"/>,
<Ref Func="UnionBlist" Label="for a list"/>,
<Ref Func="IntersectionBlist" Label="for a list"/>
and <Ref Func="DifferenceBlist"/> are known
to be boolean lists by construction, and thus
are represented in the compact representation upon creation.
<P/>
If an argument of <Ref Func="IsSubsetBlist"/>,
<Ref Func="ListBlist"/>, <Ref Func="UnionBlist" Label="for a list"/>,
<Ref Func="IntersectionBlist" Label="for a list"/>,
<Ref Func="DifferenceBlist"/>,
<Ref Func="UniteBlist"/>, <Ref Func="IntersectBlist"/> and
<Ref Func="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, an error is signalled. If it is, the
representation of the list is changed to the compact representation.
<P/>
If you change a boolean list that is represented in the compact
representation by assignment (see <Ref Sect="List Assignment"/>) or
<Ref Oper="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.
<#Include Label="IsBlistRep">
</Section>
</Chapter>
|