| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
% File: bitset.dtx |
| 4 |
% Version: 2019/12/09 v1.3 |
| 5 |
% Info: Handle bit-vector datatype |
| 6 |
% |
| 7 |
% Copyright (C) |
| 8 |
% 2007, 2011 Heiko Oberdiek |
| 9 |
% 2016-2019 Oberdiek Package Support Group |
| 10 |
% https://github.com/ho-tex/bitset/issues |
| 11 |
% |
| 12 |
% This work may be distributed and/or modified under the |
| 13 |
% conditions of the LaTeX Project Public License, either |
| 14 |
% version 1.3c of this license or (at your option) any later |
| 15 |
% version. This version of this license is in |
| 16 |
% https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 17 |
% and the latest version of this license is in |
| 18 |
% https://www.latex-project.org/lppl.txt |
| 19 |
% and version 1.3 or later is part of all distributions of |
| 20 |
% LaTeX version 2005/12/01 or later. |
| 21 |
% |
| 22 |
% This work has the LPPL maintenance status "maintained". |
| 23 |
% |
| 24 |
% The Current Maintainers of this work are |
| 25 |
% Heiko Oberdiek and the Oberdiek Package Support Group |
| 26 |
% https://github.com/ho-tex/bitset/issues |
| 27 |
% |
| 28 |
% The Base Interpreter refers to any `TeX-Format', |
| 29 |
% because some files are installed in TDS:tex/generic//. |
| 30 |
% |
| 31 |
% This work consists of the main source file bitset.dtx |
| 32 |
% and the derived files |
| 33 |
% bitset.sty, bitset.pdf, bitset.ins, bitset.drv, bitset-test1.tex, |
| 34 |
% bitset-test2.tex, bitset-test3.tex. |
| 35 |
% |
| 36 |
% Distribution: |
| 37 |
% CTAN:macros/latex/contrib/bitset/bitset.dtx |
| 38 |
% CTAN:macros/latex/contrib/bitset/bitset.pdf |
| 39 |
% |
| 40 |
% Unpacking: |
| 41 |
% (a) If bitset.ins is present: |
| 42 |
% tex bitset.ins |
| 43 |
% (b) Without bitset.ins: |
| 44 |
% tex bitset.dtx |
| 45 |
% (c) If you insist on using LaTeX |
| 46 |
% latex \let\install=y\input{bitset.dtx} |
| 47 |
% (quote the arguments according to the demands of your shell) |
| 48 |
% |
| 49 |
% Documentation: |
| 50 |
% (a) If bitset.drv is present: |
| 51 |
% latex bitset.drv |
| 52 |
% (b) Without bitset.drv: |
| 53 |
% latex bitset.dtx; ... |
| 54 |
% The class ltxdoc loads the configuration file ltxdoc.cfg |
| 55 |
% if available. Here you can specify further options, e.g. |
| 56 |
% use A4 as paper format: |
| 57 |
% \PassOptionsToClass{a4paper}{article} |
| 58 |
% |
| 59 |
% Programm calls to get the documentation (example): |
| 60 |
% pdflatex bitset.dtx |
| 61 |
% makeindex -s gind.ist bitset.idx |
| 62 |
% pdflatex bitset.dtx |
| 63 |
% makeindex -s gind.ist bitset.idx |
| 64 |
% pdflatex bitset.dtx |
| 65 |
% |
| 66 |
% Installation: |
| 67 |
% TDS:tex/generic/bitset/bitset.sty |
| 68 |
% TDS:doc/latex/bitset/bitset.pdf |
| 69 |
% TDS:source/latex/bitset/bitset.dtx |
| 70 |
% |
| 71 |
%<*ignore> |
| 72 |
\begingroup |
| 73 |
\catcode123=1 % |
| 74 |
\catcode125=2 % |
| 75 |
\def\x{LaTeX2e}% |
| 76 |
\expandafter\endgroup |
| 77 |
\ifcase 0\ifx\install y1\fi\expandafter |
| 78 |
\ifx\csname processbatchFile\endcsname\relax\else1\fi |
| 79 |
\ifx\fmtname\x\else 1\fi\relax |
| 80 |
\else\csname fi\endcsname |
| 81 |
%</ignore> |
| 82 |
%<*install> |
| 83 |
\input docstrip.tex |
| 84 |
\Msg{************************************************************************} |
| 85 |
\Msg{* Installation} |
| 86 |
\Msg{* Package: bitset 2019/12/09 v1.3 Handle bit-vector datatype (HO)} |
| 87 |
\Msg{************************************************************************} |
| 88 |
|
| 89 |
\keepsilent |
| 90 |
\askforoverwritefalse |
| 91 |
|
| 92 |
\let\MetaPrefix\relax |
| 93 |
\preamble |
| 94 |
|
| 95 |
This is a generated file. |
| 96 |
|
| 97 |
Project: bitset |
| 98 |
Version: 2019/12/09 v1.3 |
| 99 |
|
| 100 |
Copyright (C) |
| 101 |
2007, 2011 Heiko Oberdiek |
| 102 |
2016-2019 Oberdiek Package Support Group |
| 103 |
|
| 104 |
This work may be distributed and/or modified under the |
| 105 |
conditions of the LaTeX Project Public License, either |
| 106 |
version 1.3c of this license or (at your option) any later |
| 107 |
version. This version of this license is in |
| 108 |
https://www.latex-project.org/lppl/lppl-1-3c.txt |
| 109 |
and the latest version of this license is in |
| 110 |
https://www.latex-project.org/lppl.txt |
| 111 |
and version 1.3 or later is part of all distributions of |
| 112 |
LaTeX version 2005/12/01 or later. |
| 113 |
|
| 114 |
This work has the LPPL maintenance status "maintained". |
| 115 |
|
| 116 |
The Current Maintainers of this work are |
| 117 |
Heiko Oberdiek and the Oberdiek Package Support Group |
| 118 |
https://github.com/ho-tex/bitset/issues |
| 119 |
|
| 120 |
|
| 121 |
The Base Interpreter refers to any `TeX-Format', |
| 122 |
because some files are installed in TDS:tex/generic//. |
| 123 |
|
| 124 |
This work consists of the main source file bitset.dtx |
| 125 |
and the derived files |
| 126 |
bitset.sty, bitset.pdf, bitset.ins, bitset.drv, bitset-test1.tex, |
| 127 |
bitset-test2.tex, bitset-test3.tex. |
| 128 |
|
| 129 |
\endpreamble |
| 130 |
\let\MetaPrefix\DoubleperCent |
| 131 |
|
| 132 |
\generate{% |
| 133 |
\file{bitset.ins}{\from{bitset.dtx}{install}}% |
| 134 |
\file{bitset.drv}{\from{bitset.dtx}{driver}}% |
| 135 |
\usedir{tex/generic/bitset}% |
| 136 |
\file{bitset.sty}{\from{bitset.dtx}{package}}% |
| 137 |
} |
| 138 |
|
| 139 |
\catcode32=13\relax% active space |
| 140 |
\let =\space% |
| 141 |
\Msg{************************************************************************} |
| 142 |
\Msg{*} |
| 143 |
\Msg{* To finish the installation you have to move the following} |
| 144 |
\Msg{* file into a directory searched by TeX:} |
| 145 |
\Msg{*} |
| 146 |
\Msg{* bitset.sty} |
| 147 |
\Msg{*} |
| 148 |
\Msg{* To produce the documentation run the file `bitset.drv'} |
| 149 |
\Msg{* through LaTeX.} |
| 150 |
\Msg{*} |
| 151 |
\Msg{* Happy TeXing!} |
| 152 |
\Msg{*} |
| 153 |
\Msg{************************************************************************} |
| 154 |
|
| 155 |
\endbatchfile |
| 156 |
%</install> |
| 157 |
%<*ignore> |
| 158 |
\fi |
| 159 |
%</ignore> |
| 160 |
%<*driver> |
| 161 |
\NeedsTeXFormat{LaTeX2e} |
| 162 |
\ProvidesFile{bitset.drv}% |
| 163 |
[2019/12/09 v1.3 Handle bit-vector datatype (HO)]% |
| 164 |
\documentclass{ltxdoc} |
| 165 |
\usepackage{holtxdoc}[2011/11/22] |
| 166 |
\usepackage{amstext} |
| 167 |
\usepackage{iftex} |
| 168 |
\ifluatex |
| 169 |
\else |
| 170 |
\usepackage[T1]{fontenc}% |
| 171 |
\usepackage{lmodern}% |
| 172 |
\fi |
| 173 |
\begin{document} |
| 174 |
\DocInput{bitset.dtx}% |
| 175 |
\end{document} |
| 176 |
%</driver> |
| 177 |
% \fi |
| 178 |
% |
| 179 |
% |
| 180 |
% |
| 181 |
% \GetFileInfo{bitset.drv} |
| 182 |
% |
| 183 |
% \title{The \xpackage{bitset} package} |
| 184 |
% \date{2019/12/09 v1.3} |
| 185 |
% \author{Heiko Oberdiek\thanks |
| 186 |
% {Please report any issues at \url{https://github.com/ho-tex/bitset/issues}}} |
| 187 |
% |
| 188 |
% \maketitle |
| 189 |
% |
| 190 |
% \begin{abstract} |
| 191 |
% This package defines and implements the data type bit set, |
| 192 |
% a vector of bits. The size of the vector may grow dynamically. |
| 193 |
% Individual bits can be manipulated. |
| 194 |
% \end{abstract} |
| 195 |
% |
| 196 |
% \tableofcontents |
| 197 |
% |
| 198 |
% \clearpage |
| 199 |
% \section{Documentation} |
| 200 |
% |
| 201 |
% \subsection{Introduction} |
| 202 |
% |
| 203 |
% Annotations in the PDF format know entries whose values are |
| 204 |
% integers. This numbers are interpreted as set of flags |
| 205 |
% specifying properties. For example, annotation dictionaries |
| 206 |
% can have a key |/F|. The bits of its integer value |
| 207 |
% are interpreted the following way: |
| 208 |
% \begin{quote} |
| 209 |
% \begin{tabular}{@{}l|l@{}} |
| 210 |
% Bit position & Property name\\ |
| 211 |
% \hline |
| 212 |
% 1 & Invisible\\ |
| 213 |
% 2 & Hidden\\ |
| 214 |
% 3 & Print\\ |
| 215 |
% 4 & NoZoom\\ |
| 216 |
% 5 & NoRotate\\ |
| 217 |
% 6 & NoView\\ |
| 218 |
% 7 & ReadOnly\\ |
| 219 |
% \dots & \dots |
| 220 |
% \end{tabular} |
| 221 |
% \end{quote} |
| 222 |
% Now, let's see how these values are set in package \xpackage{hyperref} |
| 223 |
% before it uses this package (before v6.77a): |
| 224 |
%\begin{quote} |
| 225 |
%\begin{verbatim} |
| 226 |
%\ifFld@hidden /F 6\else /F 4\fi |
| 227 |
%\end{verbatim} |
| 228 |
%\end{quote} |
| 229 |
% Where are the other flags? The following example for key |/Ff| |
| 230 |
% in a widget annotation |
| 231 |
% supports at least three properties: |
| 232 |
%\begin{quote} |
| 233 |
%\begin{verbatim} |
| 234 |
%\ifFld@multiline |
| 235 |
% \ifFld@readonly /Ff 4097\else /Ff 4096\fi |
| 236 |
%\else |
| 237 |
% \ifFld@password |
| 238 |
% \ifFld@readonly /Ff 8193\else /Ff 8192\fi |
| 239 |
% \else |
| 240 |
% \ifFld@readonly /Ff 1\fi |
| 241 |
% \fi |
| 242 |
%\fi |
| 243 |
%\end{verbatim} |
| 244 |
%\end{quote} |
| 245 |
% But you see the point. It would be a nightmare to continue |
| 246 |
% this way in supporting the missing flag settings. This kind |
| 247 |
% of integers may have up to 32 bits. |
| 248 |
% |
| 249 |
% Therefore I wanted a data structure for setting and |
| 250 |
% clearing individual bits. Also it should provide |
| 251 |
% an export as decimal number. The snipsets above are |
| 252 |
% executed in expansion contexts without \TeX's stomach |
| 253 |
% commands. It would be convenient to have an expandable |
| 254 |
% conversion from the data structure to the integer that |
| 255 |
% gets written to the PDF file. |
| 256 |
% |
| 257 |
% This package \xpackage{bitset} implements such a data |
| 258 |
% structure. The interface is quite close to Java's |
| 259 |
% class |BitSet| in order not to learn to many interfaces |
| 260 |
% for the same kind of data structure. |
| 261 |
% |
| 262 |
% \subsection{Glossary} |
| 263 |
% |
| 264 |
% \begin{description} |
| 265 |
% \item[Bit set:] |
| 266 |
% A bit set is a vector of bits or flags. |
| 267 |
% The vector size is unlimited and |
| 268 |
% grows dynamically. An undefined bit set is treated as bit |
| 269 |
% set where all bits are cleared. |
| 270 |
% |
| 271 |
% Bit sets are addressed by name. A name should consists of |
| 272 |
% letters or digits. Technically it must survive \cs{csname}, |
| 273 |
% see \LaTeX's environment names for other names with such |
| 274 |
% a constraint. Package \xpackage{babel}'s shorthands are |
| 275 |
% not supported due to technical reasons. Shorthand support |
| 276 |
% would break expandable operations. |
| 277 |
% \item[Size:] |
| 278 |
% A size of a bit set is the number of bits in use. |
| 279 |
% It's the number of the highest index, incremented by one. |
| 280 |
% Sizes are in the range |0| up to |2147483647|, the highest |
| 281 |
% number supported by \TeX. |
| 282 |
% \item[Index:] |
| 283 |
% Bit positions in a bit set are addressed by an index number. |
| 284 |
% The bit vector is zero based. The first and least significant |
| 285 |
% bit is addressed by index |0| and the highest possible bit |
| 286 |
% by |2147483646|. |
| 287 |
% \item[Bit:] |
| 288 |
% A bit is enoded as |0| for cleared/disabled or |1| for set/enabled. |
| 289 |
% \end{description} |
| 290 |
% |
| 291 |
% \subsection{Design principles} |
| 292 |
% |
| 293 |
% \begin{description} |
| 294 |
% \item[Name conventions:] |
| 295 |
% To avoid conflicts with existing macro names, the operations |
| 296 |
% are prefixed by the package name. |
| 297 |
% \item[Zero based indexes:] The first bit is addressed by zero. |
| 298 |
% (Convention of array indexing in C, Java, \dots) |
| 299 |
% \item[Unlimited size:] |
| 300 |
% There is no restriction on the size of a bit set other than |
| 301 |
% usual memory limitations. \cs{bitsetSetDec} and \cs{bitsetGetDec} |
| 302 |
% transparently switch to package \xpackage{bigintcalc} if the numbers |
| 303 |
% get too large for \TeX's number limit. |
| 304 |
% \item[Expandibility:] |
| 305 |
% Any operation that does not change the bit set is expandable. |
| 306 |
% And all operations that extract or calculate some result |
| 307 |
% do this in exact two expansion steps. For example, |
| 308 |
% a macro \cs{Macro} wants a bit set as decimal number. |
| 309 |
% But the argument must be a plain number without macros. |
| 310 |
% Thus you could prefix \cs{bitsetGetDec} with \cs{number}. |
| 311 |
% However this won't work for bit sets with 31 or more bits |
| 312 |
% because of \TeX's number limit of $2^{31}-1$. |
| 313 |
% then just hit the operator with two \cs{expandafter}: |
| 314 |
% \begin{quote} |
| 315 |
% |\expandafter\expandafter\expandafter|\\ |
| 316 |
% |\Macro\bitsetGetDec{foo}| |
| 317 |
% \end{quote} |
| 318 |
% |\bitsetGetDec| is hit first by the third \cs{expandafter} |
| 319 |
% and then by the second one. |
| 320 |
% \item[Format independence:] This package is written as \LaTeX\ package, |
| 321 |
% but it does not depend on \LaTeX. It will also work for other formats |
| 322 |
% such as \plainTeX. |
| 323 |
% \item[Independence from \TeX\ engines:] |
| 324 |
% Vanilla \TeX\ is all you need. Calculations are delegated to |
| 325 |
% packages \xpackage{intcalc} and \xpackage{bigintcalc}. |
| 326 |
% They don't need any special features, but they will switch |
| 327 |
% to a little more efficient implementation if features such |
| 328 |
% as \cs{numexpr} are available. |
| 329 |
% \item[Numeric arguments:] Anything that is accepted by |
| 330 |
% \cs{number}. If \eTeX\ is detected, also expressions |
| 331 |
% for \cs{numexpr} are supported. The only exception so far |
| 332 |
% is the number for \cs{bitsetSetDec}. The number might be too |
| 333 |
% large for \cs{number} or \cs{numexpr}. |
| 334 |
% \item[Error messages:] |
| 335 |
% In expandable contexts, only a limited set of \TeX\ primitive |
| 336 |
% commands work as expected. So called stomach commands behave |
| 337 |
% like \cs{relax} and don't get expanded or executed. |
| 338 |
% Unhappily also the error commands belong to this category. |
| 339 |
% The expandable operations will throw an unknown control |
| 340 |
% sequence instead to get \TeX's and user's attention. |
| 341 |
% The name of these control sequences starts with |
| 342 |
% \cs{BitSetError:} with the type of error after the colon. |
| 343 |
% \end{description} |
| 344 |
% |
| 345 |
% \subsection{Operator overview} |
| 346 |
% |
| 347 |
% \begin{minipage}{\linewidth} |
| 348 |
% \begin{description} |
| 349 |
% \def\It#1#2{^^A |
| 350 |
% \item[^^A |
| 351 |
% {#1} ^^A |
| 352 |
% \textmd{(\hyperref[{sec:#2}]{section \ref*{sec:#2}})}^^A |
| 353 |
% ]^^A |
| 354 |
% \mbox{}\\^^A |
| 355 |
% } |
| 356 |
% \def\op#1{^^A |
| 357 |
% \cs{bitset}\texttt{\bfseries#1}^^A |
| 358 |
% } |
| 359 |
% \def\M#1{\meta{#1}} |
| 360 |
% \def\Q{\hspace*{\fill}} |
| 361 |
% \It{Miscellaneous}{misc} |
| 362 |
% \op{Reset}\Q \M{BitSet}\\ |
| 363 |
% \op{Let}\Q \M{BitSet A} \M{BitSet B} |
| 364 |
% \It{Import}{import} |
| 365 |
% \op{SetBin}, \op{SetOct}, \op{SetHex}\Q \M{BitSet} \M{Value}\\ |
| 366 |
% \op{SetDec}\Q \M{BitSet} \M{Value} |
| 367 |
% \It{Export\textsuperscript{a}}{export} |
| 368 |
% \op{GetBin}, \op{GetOct}, \op{GetHex}\Q \M{BitSet} \M{MinSize}\\ |
| 369 |
% \op{GetDec}\Q \M{BitSet} |
| 370 |
% \It{Logical operators}{log} |
| 371 |
% \op{And}, \op{AndNot}\Q \M{BitSet A} \M{BitSet B}\\ |
| 372 |
% \op{Or}, \op{Xor}\Q \M{BitSet A} \M{BitSet B} |
| 373 |
% \It{Shifting}{shift} |
| 374 |
% \op{ShiftLeft}, \op{ShiftRight}\Q \M{BitSet} \M{ShiftAmount}\\ |
| 375 |
% \It{Bit manipulation}{bitman} |
| 376 |
% \op{Clear}, \op{Set}, \op{Flip}\Q \M{BitSet} \M{Index}\\ |
| 377 |
% \op{SetValue}\Q \M{BitSet} \M{Index} \M{Value}\\ |
| 378 |
% \op{ClearRange}, \op{SetRange}, \op{FlipRange}\\ |
| 379 |
% \Q \M{BitSet} \M{IndexFrom} \M{IndexTo}\\ |
| 380 |
% \op{SetValueRange}\Q \M{BitSet} \M{IndexFrom} \M{IndexTo} |
| 381 |
% \It{Bit retrieval\textsuperscript{a}}{bitret} |
| 382 |
% \op{Get}\Q \M{BitSet} \M{Index}\\ |
| 383 |
% \op{NextClearBit}, \op{NextSetBit}\Q \M{BitSet} \M{Index}\\ |
| 384 |
% \op{GetSetBitList}\Q \M{BitSet} |
| 385 |
% \It{Bit set properties}{prop} |
| 386 |
% \op{Size}, \op{Cardinality}\Q \M{BitSet} |
| 387 |
% \It{Queries\textsuperscript{b}}{query} |
| 388 |
% \op{IsDefined}, \op{IsEmpty}\Q \M{BitSet} \M{Then} \M{Else}\\ |
| 389 |
% \op{Equals}, \op{Intersects}\Q \M{BitSet A} \M{BitSet B} \M{Then} \M{Else}\\ |
| 390 |
% \op{Query}\Q \M{BitSet} \M{Index} \M{Then} \M{Else} |
| 391 |
% \end{description} |
| 392 |
% \footnotetext[1]{Macros are expandable, full expansion by two steps.} |
| 393 |
% \footnotetext[2]{Macros are expandable.} |
| 394 |
% \end{minipage} |
| 395 |
% |
| 396 |
% \subsection{Package loading} |
| 397 |
% |
| 398 |
% The package can be used as normal \LaTeX\ package: |
| 399 |
%\begin{quote} |
| 400 |
%|\usepackage{bitset}| |
| 401 |
%\end{quote} |
| 402 |
% Also \plainTeX\ is supported: |
| 403 |
%\begin{quote} |
| 404 |
%|\input bitset.sty\relax| |
| 405 |
%\end{quote} |
| 406 |
% |
| 407 |
% \subsection{Operators} |
| 408 |
% |
| 409 |
% The following macros work on and with bit sets. |
| 410 |
% A bit set \meta{BitSet} is represented by a name. |
| 411 |
% The should consist of letters and digits. Technically |
| 412 |
% it must survive \cs{csname}. It is the same constraint |
| 413 |
% that must be satisfied by label or environment names |
| 414 |
% in \LaTeX. |
| 415 |
% |
| 416 |
% However active characters that are shorthands |
| 417 |
% of package \xpackage{babel} are not supported. |
| 418 |
% Support for shorthands works by an assignment. |
| 419 |
% But many operators |
| 420 |
% such as \cs{bitsetGetDec} must be usable in expandable |
| 421 |
% contexts. There assignments will not be executed in the |
| 422 |
% best case or they will cause errors. |
| 423 |
% |
| 424 |
% The bits in a bit set are addressed by non-negative |
| 425 |
% integers starting from zero. Thus negative index |
| 426 |
% numbers cause an error message. Because index numbers |
| 427 |
% are \TeX\ numbers. The largest index is 2147483647. |
| 428 |
% But in practice memory limits and patience limits |
| 429 |
% will be very likely reached much before. |
| 430 |
% |
| 431 |
% \subsubsection{Miscellaneous}\label{sec:misc} |
| 432 |
% |
| 433 |
% There isn't a separate operation for bit set creation. |
| 434 |
% For simplicity an undefined bit set is treated as bit set |
| 435 |
% with all bits cleared. |
| 436 |
% |
| 437 |
% \begin{declcs}{bitsetReset} \M{BitSet} |
| 438 |
% \end{declcs} |
| 439 |
% Macro \cs{bitsetReset} clears all bits. The result is an |
| 440 |
% empty bit set. It may also be used as replacement for |
| 441 |
% an operation ``new'', because an undefined bit set is defined |
| 442 |
% afterwards. |
| 443 |
% |
| 444 |
% \begin{declcs}{bitsetLet} \M{BitSet A} \M{BitSet B} |
| 445 |
% \end{declcs} |
| 446 |
% Macro \cs{bitsetLet} performs a simple assignment similar |
| 447 |
% to \TeX's \cs{let}. After the operation \meta{BitSet A} has |
| 448 |
% the same value as \meta{BitSet B}. If \meta{BitSet B} is |
| 449 |
% undefined, then \meta{BitSet A} will be the empty bit set. |
| 450 |
% |
| 451 |
% Note: If \meta{BitSet A} exists, it will be overwritten. |
| 452 |
% |
| 453 |
% \subsubsection{Import}\label{sec:import} |
| 454 |
% |
| 455 |
% \begin{declcs}{bitsetSetBin} \M{BitSet} \M{BinaryNumber}\\ |
| 456 |
% \cs{bitsetSetOct} \M{BitSet} \M{OctalNumber}\\ |
| 457 |
% \cs{bitsetSetHex} \M{BitSet} \M{HexadecimalNumber} |
| 458 |
% \end{declcs} |
| 459 |
% The numbers are interpreted as bit vectors and the flags in |
| 460 |
% the bit \meta{BitSet} set are set accordingly. |
| 461 |
% These numeric arguments are the only arguments where |
| 462 |
% spaces are allowed. Then the numbers are easier to read. |
| 463 |
% |
| 464 |
% \begin{declcs}{bitsetSetDec} \M{BitSet} \M{DecimalNumber} |
| 465 |
% \end{declcs} |
| 466 |
% Macro \cs{bitsetSetDec} uses \meta{DecimalNumber} to |
| 467 |
% set the bit set \meta{BitSet}. |
| 468 |
% The numeric argument must expand |
| 469 |
% to a plain number consisting of decimal digits without |
| 470 |
% command tokens or spaces. Internally this argument is |
| 471 |
% expanded only. It cannot be passed to \cs{number} or |
| 472 |
% \cs{numexpr}, because the number may be too large for them. |
| 473 |
% However \cs{number} or |\the\numexpr| may be used |
| 474 |
% explicitely. This also helps for unexpandable number |
| 475 |
% command tokens or registers (\cs{z@}, \cs{@ne}, \cs{count@}, \dots). |
| 476 |
% Also \LaTeX'\ \cs{value} needs prefixing: |
| 477 |
% \begin{quote} |
| 478 |
% |\bitsetSetDec{foo}{\number\value{bar}}| |
| 479 |
% \end{quote} |
| 480 |
% |
| 481 |
% \subsubsection{Export}\label{sec:export} |
| 482 |
% |
| 483 |
% \begin{declcs}{bitsetGetBin} \M{BitSet} \M{MinSize}\\ |
| 484 |
% \cs{bitsetGetOct} \M{BitSet} \M{MinSize}\\ |
| 485 |
% \cs{bitsetGetHex} \M{BitSet} \M{MinSize} |
| 486 |
% \end{declcs} |
| 487 |
% These macros returns the bit set as binary, octal or hexadecimal |
| 488 |
% number. If the bit size is smaller than \meta{MinSize} the gap is |
| 489 |
% filled with leading zeros. |
| 490 |
% Example: |
| 491 |
% \begin{quote} |
| 492 |
% |\bitsetReset{abc}|\\ |
| 493 |
% |\bitsetSet{abc}{2}|\\ |
| 494 |
% |\bitsetGetBin{abc}{8}| $\rightarrow$ |00000100|\\ |
| 495 |
% |\bitsetSet{abc}{5}\bitsetSet{abc}{7}|\\ |
| 496 |
% |\bitsetGetHex{abc}{16}| $\rightarrow$ |00A2| |
| 497 |
% \end{quote} |
| 498 |
% Macro \cs{bitsetGetHex} uses the uppercase letters |A| to |F|. |
| 499 |
% The catcode of the letters is one of 11 (letter) or 12 (other). |
| 500 |
% |
| 501 |
% \begin{declcs}{bitsetGetDec} \M{BitSet} |
| 502 |
% \end{declcs} |
| 503 |
% Macro \cs{bitsetGetDec} returns the bit set \meta{BitSet} as |
| 504 |
% decimal number. The returned number can be larger than |
| 505 |
% \TeX's number limit of $2^{31}-1$. |
| 506 |
% |
| 507 |
% \subsubsection{Logical operators}\label{sec:log} |
| 508 |
% |
| 509 |
% \begin{declcs}{bitsetAnd} \M{BitSet A} \M{BitSet B} |
| 510 |
% \end{declcs} |
| 511 |
% $A_{\text{new}} \mathrel{\mathop{:}}= A_{\text{old}} |
| 512 |
% \mathbin{\text{and}} B \qquad (\forall\, \text{bits})$ |
| 513 |
% |
| 514 |
% \begin{declcs}{bitsetAndNot} \M{BitSet A} \M{BitSet B} |
| 515 |
% \end{declcs} |
| 516 |
% $A_{\text{new}} \mathrel{\mathop{:}}= A_{\text{old}} |
| 517 |
% \mathbin{\text{and}} (\text{not}\,B) \qquad (\forall\, \text{bits})$ |
| 518 |
% |
| 519 |
% \begin{declcs}{bitsetOr} \M{BitSet A} \M{BitSet B} |
| 520 |
% \end{declcs} |
| 521 |
% $A_{\text{new}} \mathrel{\mathop{:}}= A_{\text{old}} |
| 522 |
% \mathbin{\text{or}} B \qquad (\forall\, \text{bits})$ |
| 523 |
% |
| 524 |
% \begin{declcs}{bitsetXor} \M{BitSet A} \M{BitSet B} |
| 525 |
% \end{declcs} |
| 526 |
% $A_{\text{new}} \mathrel{\mathop{:}}= A_{\text{old}} |
| 527 |
% \mathbin{\text{xor}} B \qquad (\forall\, \text{bits})$ |
| 528 |
% |
| 529 |
% \subsubsection{Shifting}\label{sec:shift} |
| 530 |
% |
| 531 |
% \begin{declcs}{bitsetShiftLeft} \M{BitSet} \M{ShiftAmount}\\ |
| 532 |
% \cs{bitsetShiftRight} \M{BitSet} \M{ShiftAmount} |
| 533 |
% \end{declcs} |
| 534 |
% A left shift by one is a multiplication by two, thus left shifting |
| 535 |
% moves the flags to higher positions. The new created low positions |
| 536 |
% are filled by zeros. |
| 537 |
% |
| 538 |
% A right shift is the opposite, dividing by two, movint the bits |
| 539 |
% to lower positions. The number will become smaller, the lowest |
| 540 |
% bits are lost. |
| 541 |
% |
| 542 |
% If the \meta{ShiftAmount} is negative, it reverts the meaning of |
| 543 |
% the shift operation. A left shift becomes a right shift. |
| 544 |
% A \meta{ShiftAmount} of zero is ignored. |
| 545 |
% |
| 546 |
% \subsubsection{Bit manipulation}\label{sec:bitman} |
| 547 |
% |
| 548 |
% \begin{declcs}{bitsetClear} \M{BitSet} \M{Index}\\ |
| 549 |
% \cs{bitsetSet} \M{BitSet} \M{Index}\\ |
| 550 |
% \cs{bitsetFlip} \M{BitSet} \M{Index} |
| 551 |
% \end{declcs} |
| 552 |
% This macros manipulate a single bit in \meta{BitSet} addressed |
| 553 |
% by \cs{Index}. Macro \cs{bitsetClear} disables the bit, |
| 554 |
% \cs{bitsetSet} enables it and \cs{bitsetFlip} reverts the current |
| 555 |
% setting of the bit. |
| 556 |
% |
| 557 |
% \begin{declcs}{bitsetSetValue} \M{BitSet} \M{Index} \M{Bit} |
| 558 |
% \end{declcs} |
| 559 |
% Macro \cs{bitsetSetValue} puts bit \meta{Bit} at position \meta{Index} |
| 560 |
% in bit set \meta{BitSet}. \meta{Bit} must be a valid \TeX\ number |
| 561 |
% equals to zero (disabled/cleared) or one (enabled/set). |
| 562 |
% |
| 563 |
% \subsubsection{Bit retrieval}\label{sec:bitret} |
| 564 |
% |
| 565 |
% \begin{declcs}{bitsetGet} \M{BitSet} \M{Index} |
| 566 |
% \end{declcs} |
| 567 |
% Macro \cs{bitsetGet} extracts the status of the bit at |
| 568 |
% position \meta{Index} in bit set \meta{BitSet}. |
| 569 |
% Digit |1| is returned if the bit is set/enabled. If the |
| 570 |
% bit is cleared/disabled and in cases of an undefined bitset or |
| 571 |
% an index number out of range the return value is |0|. |
| 572 |
% |
| 573 |
% \begin{declcs}{bitsetNextClearBit} \M{BitSet} \M{Index} |
| 574 |
% \end{declcs} |
| 575 |
% Starting at position \meta{Index} (inclusive) the bits |
| 576 |
% are inspected. The first position without a set bit is returned. |
| 577 |
% Possible results are decimal numbers: \meta{Index}, \meta{Index} + 1, |
| 578 |
% \dots, ($\infty$) |
| 579 |
% |
| 580 |
% \begin{declcs}{bitsetNextSetBit} \M{BitSet} \M{Index} |
| 581 |
% \end{declcs} |
| 582 |
% Starting at position \meta{Index} (inclusive) the bits are |
| 583 |
% inspected and the index position of the first found set bit |
| 584 |
% is returned. If there isn't such a bit, then the result is |
| 585 |
% |-1|. In summary possible results are decimal numbers: |
| 586 |
% |-1|, \meta{Index}, \meta{Index} + 1, \dots, ($\infty$) |
| 587 |
% |
| 588 |
% \begin{declcs}{bitsetGetSetBitList} \M{BitSet} |
| 589 |
% \end{declcs} |
| 590 |
% Macro \cs{bitsetGetSetBitList} is an application for |
| 591 |
% \cs{bitsetNextSetBit}. The set bits are iterated and |
| 592 |
% returned as comma separated list of index positions |
| 593 |
% in increasing order. The list is empty in case of |
| 594 |
% an empty bit set. |
| 595 |
% |
| 596 |
% \subsubsection{Bit set properties}\label{sec:prop} |
| 597 |
% |
| 598 |
% \begin{declcs}{bitsetSize} \M{BitSet} |
| 599 |
% \end{declcs} |
| 600 |
% Macro \cs{bitsetSize} returns number of bits in use. |
| 601 |
% It is the same as the index number of the highest set/enabled bit |
| 602 |
% incremented by one. |
| 603 |
% |
| 604 |
% \begin{declcs}{bitsetCardinality} \M{BitSet} |
| 605 |
% \end{declcs} |
| 606 |
% Macro \cs{bitsetCardinality} counts the number of set/enabled bits. |
| 607 |
% |
| 608 |
% \subsubsection{Queries}\label{sec:query} |
| 609 |
% |
| 610 |
% Also the query procedures are expandable. They ask for a piece |
| 611 |
% of information about a bit set and execute code depending |
| 612 |
% on the answer. |
| 613 |
% |
| 614 |
% \begin{declcs}{bitsetIsDefined} \M{BitSet} \M{Then} \M{Else} |
| 615 |
% \end{declcs} |
| 616 |
% If the bit set with the name \meta{BitSet} exists the code |
| 617 |
% given in \meta{Then} is executed, otherwise \meta{Else} is used. |
| 618 |
% |
| 619 |
% \begin{declcs}{bitsetIsEmpty} \M{BitSet} \M{Then} \M{Else} |
| 620 |
% \end{declcs} |
| 621 |
% If the bit set \meta{BitSet} exists and at least one bit |
| 622 |
% is set/enabled, the code in \meta{Then} is executed, |
| 623 |
% \meta{Else} otherwise. |
| 624 |
% |
| 625 |
% \begin{declcs}{bitsetEquals} \M{BitSet A} \M{BitSet B} \M{Then} \M{Else} |
| 626 |
% \end{declcs} |
| 627 |
% Both bit sets are equal if and only if either both are undefined |
| 628 |
% or both are defined and represents the same bit values at the |
| 629 |
% same positions. Thus this definition is reflexive, symmeric, |
| 630 |
% and transitive, enough for an equivalent relation. |
| 631 |
% |
| 632 |
% \begin{declcs}{bitsetIntersects} \M{BitSet A} \M{BitSet B} \M{Then} \M{Else} |
| 633 |
% \end{declcs} |
| 634 |
% If and only if \meta{BitSet A} and \meta{BitSet B} have |
| 635 |
% at least one bit at the same position that is set, then |
| 636 |
% code part \meta{Then} is executed. |
| 637 |
% |
| 638 |
% \begin{declcs}{bitsetQuery} \M{BitSet} \M{Index} \M{Then} \M{Else} |
| 639 |
% \end{declcs} |
| 640 |
% It's just a wrapper for \cs{bitsetGet}. If the bit at position |
| 641 |
% \meta{Index} is enabled, code \meta{Then} is called. |
| 642 |
% |
| 643 |
% \StopEventually{ |
| 644 |
% } |
| 645 |
% |
| 646 |
% \section{Implementation} |
| 647 |
% |
| 648 |
% The internal format of a bit set is quite simple, a sequence |
| 649 |
% of digits |0| and |1|. The least significant bit is left. |
| 650 |
% A bit set without any flag set is encoded by |0|. Also |
| 651 |
% undefined bit sets are treated that way. After the |
| 652 |
% highest bit that is set there are no further zeroes. |
| 653 |
% A regular expression of valid bit sets values: |
| 654 |
% \begin{quote} |
| 655 |
% |0|\string||[01]*1| |
| 656 |
% \end{quote} |
| 657 |
% |
| 658 |
% \begin{macrocode} |
| 659 |
%<*package> |
| 660 |
% \end{macrocode} |
| 661 |
% |
| 662 |
% \subsection{Reload check and package identification} |
| 663 |
% Reload check, especially if the package is not used with \LaTeX. |
| 664 |
% \begin{macrocode} |
| 665 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 666 |
\catcode13=5 % ^^M |
| 667 |
\endlinechar=13 % |
| 668 |
\catcode35=6 % # |
| 669 |
\catcode39=12 % ' |
| 670 |
\catcode44=12 % , |
| 671 |
\catcode45=12 % - |
| 672 |
\catcode46=12 % . |
| 673 |
\catcode58=12 % : |
| 674 |
\catcode64=11 % @ |
| 675 |
\catcode123=1 % { |
| 676 |
\catcode125=2 % } |
| 677 |
\expandafter\let\expandafter\x\csname [email protected]\endcsname |
| 678 |
\ifx\x\relax % plain-TeX, first loading |
| 679 |
\else |
| 680 |
\def\empty{}% |
| 681 |
\ifx\x\empty % LaTeX, first loading, |
| 682 |
% variable is initialized, but \ProvidesPackage not yet seen |
| 683 |
\else |
| 684 |
\expandafter\ifx\csname PackageInfo\endcsname\relax |
| 685 |
\def\x#1#2{% |
| 686 |
\immediate\write-1{Package #1 Info: #2.}% |
| 687 |
}% |
| 688 |
\else |
| 689 |
\def\x#1#2{\PackageInfo{#1}{#2, stopped}}% |
| 690 |
\fi |
| 691 |
\x{bitset}{The package is already loaded}% |
| 692 |
\aftergroup\endinput |
| 693 |
\fi |
| 694 |
\fi |
| 695 |
\endgroup% |
| 696 |
% \end{macrocode} |
| 697 |
% Package identification: |
| 698 |
% \begin{macrocode} |
| 699 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 700 |
\catcode13=5 % ^^M |
| 701 |
\endlinechar=13 % |
| 702 |
\catcode35=6 % # |
| 703 |
\catcode39=12 % ' |
| 704 |
\catcode40=12 % ( |
| 705 |
\catcode41=12 % ) |
| 706 |
\catcode44=12 % , |
| 707 |
\catcode45=12 % - |
| 708 |
\catcode46=12 % . |
| 709 |
\catcode47=12 % / |
| 710 |
\catcode58=12 % : |
| 711 |
\catcode64=11 % @ |
| 712 |
\catcode91=12 % [ |
| 713 |
\catcode93=12 % ] |
| 714 |
\catcode123=1 % { |
| 715 |
\catcode125=2 % } |
| 716 |
\expandafter\ifx\csname ProvidesPackage\endcsname\relax |
| 717 |
\def\x#1#2#3[#4]{\endgroup |
| 718 |
\immediate\write-1{Package: #3 #4}% |
| 719 |
\xdef#1{#4}% |
| 720 |
}% |
| 721 |
\else |
| 722 |
\def\x#1#2[#3]{\endgroup |
| 723 |
#2[{#3}]% |
| 724 |
\ifx#1\@undefined |
| 725 |
\xdef#1{#3}% |
| 726 |
\fi |
| 727 |
\ifx#1\relax |
| 728 |
\xdef#1{#3}% |
| 729 |
\fi |
| 730 |
}% |
| 731 |
\fi |
| 732 |
\expandafter\x\csname [email protected]\endcsname |
| 733 |
\ProvidesPackage{bitset}% |
| 734 |
[2019/12/09 v1.3 Handle bit-vector datatype (HO)]% |
| 735 |
% \end{macrocode} |
| 736 |
% |
| 737 |
% \subsection{Catcodes} |
| 738 |
% |
| 739 |
% \begin{macrocode} |
| 740 |
\begingroup\catcode61\catcode48\catcode32=10\relax% |
| 741 |
\catcode13=5 % ^^M |
| 742 |
\endlinechar=13 % |
| 743 |
\catcode123=1 % { |
| 744 |
\catcode125=2 % } |
| 745 |
\catcode64=11 % @ |
| 746 |
\def\x{\endgroup |
| 747 |
\expandafter\edef\csname BitSet@AtEnd\endcsname{% |
| 748 |
\endlinechar=\the\endlinechar\relax |
| 749 |
\catcode13=\the\catcode13\relax |
| 750 |
\catcode32=\the\catcode32\relax |
| 751 |
\catcode35=\the\catcode35\relax |
| 752 |
\catcode61=\the\catcode61\relax |
| 753 |
\catcode64=\the\catcode64\relax |
| 754 |
\catcode123=\the\catcode123\relax |
| 755 |
\catcode125=\the\catcode125\relax |
| 756 |
}% |
| 757 |
}% |
| 758 |
\x\catcode61\catcode48\catcode32=10\relax% |
| 759 |
\catcode13=5 % ^^M |
| 760 |
\endlinechar=13 % |
| 761 |
\catcode35=6 % # |
| 762 |
\catcode64=11 % @ |
| 763 |
\catcode123=1 % { |
| 764 |
\catcode125=2 % } |
| 765 |
\def\TMP@EnsureCode#1#2{% |
| 766 |
\edef\BitSet@AtEnd{% |
| 767 |
\BitSet@AtEnd |
| 768 |
\catcode#1=\the\catcode#1\relax |
| 769 |
}% |
| 770 |
\catcode#1=#2\relax |
| 771 |
} |
| 772 |
\TMP@EnsureCode{33}{12}% ! |
| 773 |
\TMP@EnsureCode{39}{12}% ' |
| 774 |
\TMP@EnsureCode{40}{12}% ( |
| 775 |
\TMP@EnsureCode{41}{12}% ) |
| 776 |
\TMP@EnsureCode{42}{12}% * |
| 777 |
\TMP@EnsureCode{43}{12}% + |
| 778 |
\TMP@EnsureCode{44}{12}% , |
| 779 |
\TMP@EnsureCode{45}{12}% - |
| 780 |
\TMP@EnsureCode{46}{12}% . |
| 781 |
\TMP@EnsureCode{47}{12}% / |
| 782 |
\TMP@EnsureCode{58}{11}% : (letter!) |
| 783 |
\TMP@EnsureCode{60}{12}% < |
| 784 |
\TMP@EnsureCode{62}{12}% > |
| 785 |
\TMP@EnsureCode{63}{14}% ? (comment!) |
| 786 |
\TMP@EnsureCode{91}{12}% [ |
| 787 |
\TMP@EnsureCode{93}{12}% ] |
| 788 |
\TMP@EnsureCode{96}{12}% ` |
| 789 |
\edef\BitSet@AtEnd{\BitSet@AtEnd\noexpand\endinput} |
| 790 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 791 |
\expandafter\ifx\csname BitSet@TestMode\endcsname\relax |
| 792 |
\else |
| 793 |
\catcode63=9 % ? (ignore) |
| 794 |
\fi |
| 795 |
? \let\BitSet@@TestMode\BitSet@TestMode |
| 796 |
% \end{macrocode} |
| 797 |
% |
| 798 |
% \subsection{Package loading} |
| 799 |
% |
| 800 |
% \begin{macrocode} |
| 801 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 802 |
\expandafter\ifx\csname RequirePackage\endcsname\relax |
| 803 |
\def\TMP@RequirePackage#1[#2]{% |
| 804 |
\begingroup\expandafter\expandafter\expandafter\endgroup |
| 805 |
\expandafter\ifx\csname ver@#1.sty\endcsname\relax |
| 806 |
\input #1.sty\relax |
| 807 |
\fi |
| 808 |
}% |
| 809 |
\TMP@RequirePackage{infwarerr}[2007/09/09]% |
| 810 |
\TMP@RequirePackage{intcalc}[2007/09/27]% |
| 811 |
\TMP@RequirePackage{bigintcalc}[2007/09/27]% |
| 812 |
\else |
| 813 |
\RequirePackage{infwarerr}[2007/09/09]% |
| 814 |
\RequirePackage{intcalc}[2007/09/27]% |
| 815 |
\RequirePackage{bigintcalc}[2007/09/27]% |
| 816 |
\fi |
| 817 |
% \end{macrocode} |
| 818 |
% |
| 819 |
% \subsection{Help macros} |
| 820 |
% |
| 821 |
% \subsubsection{Number constant} |
| 822 |
% |
| 823 |
% \begin{macro}{\BitSet@MaxSize} |
| 824 |
% \begin{macrocode} |
| 825 |
\def\BitSet@MaxSize{2147483647}% |
| 826 |
% \end{macrocode} |
| 827 |
% \end{macro} |
| 828 |
% |
| 829 |
% \subsubsection{General basic macros} |
| 830 |
% |
| 831 |
% \begin{macro}{\BitSet@Empty} |
| 832 |
% \begin{macrocode} |
| 833 |
\def\BitSet@Empty{} |
| 834 |
% \end{macrocode} |
| 835 |
% \end{macro} |
| 836 |
% \begin{macro}{\BitSet@FirstOfOne} |
| 837 |
% \begin{macrocode} |
| 838 |
\def\BitSet@FirstOfOne#1{#1} |
| 839 |
% \end{macrocode} |
| 840 |
% \end{macro} |
| 841 |
% \begin{macro}{\BitSet@Gobble} |
| 842 |
% \begin{macrocode} |
| 843 |
\def\BitSet@Gobble#1{} |
| 844 |
% \end{macrocode} |
| 845 |
% \end{macro} |
| 846 |
% \begin{macro}{\BitSet@FirstOfTwo} |
| 847 |
% \begin{macrocode} |
| 848 |
\def\BitSet@FirstOfTwo#1#2{#1} |
| 849 |
% \end{macrocode} |
| 850 |
% \end{macro} |
| 851 |
% \begin{macro}{\BitSet@SecondOfTwo} |
| 852 |
% \begin{macrocode} |
| 853 |
\def\BitSet@SecondOfTwo#1#2{#2} |
| 854 |
% \end{macrocode} |
| 855 |
% \end{macro} |
| 856 |
% |
| 857 |
% \begin{macro}{\BitSet@Space} |
| 858 |
% \begin{macrocode} |
| 859 |
\def\BitSet@Space{ } |
| 860 |
% \end{macrocode} |
| 861 |
% \end{macro} |
| 862 |
% \begin{macro}{\BitSet@ZapSpace} |
| 863 |
% \begin{macrocode} |
| 864 |
\def\BitSet@ZapSpace#1 #2{% |
| 865 |
#1% |
| 866 |
\ifx\BitSet@Empty#2% |
| 867 |
\else |
| 868 |
\expandafter\BitSet@ZapSpace |
| 869 |
\fi |
| 870 |
#2% |
| 871 |
} |
| 872 |
% \end{macrocode} |
| 873 |
% \end{macro} |
| 874 |
% |
| 875 |
% \subsubsection{Tail recursion} |
| 876 |
% |
| 877 |
% \begin{macro}{\BitSet@Fi} |
| 878 |
% \begin{macrocode} |
| 879 |
\let\BitSet@Fi\fi |
| 880 |
% \end{macrocode} |
| 881 |
% \end{macro} |
| 882 |
% \begin{macro}{\BitSet@AfterFi} |
| 883 |
% \begin{macrocode} |
| 884 |
\def\BitSet@AfterFi#1#2\BitSet@Fi{\fi#1} |
| 885 |
% \end{macrocode} |
| 886 |
% \end{macro} |
| 887 |
% \begin{macro}{\BitSet@AfterFiFi} |
| 888 |
% \begin{macrocode} |
| 889 |
\def\BitSet@AfterFiFi#1#2\BitSet@Fi{\fi\fi#1}% |
| 890 |
% \end{macrocode} |
| 891 |
% \end{macro} |
| 892 |
% \begin{macro}{\BitSet@AfterFiFiFi} |
| 893 |
% \begin{macrocode} |
| 894 |
\def\BitSet@AfterFiFiFi#1#2\BitSet@Fi{\fi\fi\fi#1}% |
| 895 |
% \end{macrocode} |
| 896 |
% \end{macro} |
| 897 |
% |
| 898 |
% \subsubsection{Check macros} |
| 899 |
% |
| 900 |
% \begin{macro}{\BitSet@IfUndefined} |
| 901 |
% \begin{macrocode} |
| 902 |
\def\BitSet@IfUndefined#1{% |
| 903 |
\expandafter\ifx\csname BS@#1\endcsname\relax |
| 904 |
\expandafter\BitSet@FirstOfTwo |
| 905 |
\else |
| 906 |
\expandafter\BitSet@SecondOfTwo |
| 907 |
\fi |
| 908 |
} |
| 909 |
% \end{macrocode} |
| 910 |
% \end{macro} |
| 911 |
% |
| 912 |
% \begin{macro}{\BitSet@CheckIndex} |
| 913 |
% |#1|: continuation code\\ |
| 914 |
% |#2|: BitSet\\ |
| 915 |
% |#3|: Index |
| 916 |
% \begin{macrocode} |
| 917 |
\def\BitSet@CheckIndex#1#2#3{% |
| 918 |
\BitSet@IfUndefined{#2}{\bitsetReset{#2}}{}% |
| 919 |
\expandafter\expandafter\expandafter\BitSet@@CheckIndex |
| 920 |
\intcalcNum{#3}!% |
| 921 |
{#2}{#1}% |
| 922 |
} |
| 923 |
% \end{macrocode} |
| 924 |
% \end{macro} |
| 925 |
% \begin{macro}{\BitSet@@CheckIndex} |
| 926 |
% |#1|: plain Index\\ |
| 927 |
% |#2|: BitSet\\ |
| 928 |
% |#3|: continuation code |
| 929 |
% \begin{macrocode} |
| 930 |
\def\BitSet@@CheckIndex#1!#2#3{% |
| 931 |
\ifnum#1<0 % |
| 932 |
\BitSet@AfterFi{% |
| 933 |
\@PackageError{bitset}{% |
| 934 |
Invalid negative index (#1)% |
| 935 |
}\@ehc |
| 936 |
}% |
| 937 |
\else |
| 938 |
\BitSet@AfterFi{% |
| 939 |
#3{#2}{#1}% |
| 940 |
}% |
| 941 |
\BitSet@Fi |
| 942 |
} |
| 943 |
% \end{macrocode} |
| 944 |
% \end{macro} |
| 945 |
% |
| 946 |
% \subsection{Miscellaneous}\label{src:misc} |
| 947 |
% |
| 948 |
% \begin{macro}{\bitsetReset} |
| 949 |
% \begin{macrocode} |
| 950 |
\def\bitsetReset#1{% |
| 951 |
\expandafter\def\csname BS@#1\endcsname{0}% |
| 952 |
} |
| 953 |
% \end{macrocode} |
| 954 |
% \end{macro} |
| 955 |
% |
| 956 |
% \begin{macro}{\bitsetLet} |
| 957 |
% \begin{macrocode} |
| 958 |
\def\bitsetLet#1#2{% |
| 959 |
\BitSet@IfUndefined{#2}{% |
| 960 |
\bitsetReset{#1}% |
| 961 |
}{% |
| 962 |
\expandafter\let\csname BS@#1\expandafter\endcsname |
| 963 |
\csname BS@#2\endcsname |
| 964 |
}% |
| 965 |
} |
| 966 |
% \end{macrocode} |
| 967 |
% \end{macro} |
| 968 |
% |
| 969 |
% \subsection{Import}\label{src:import} |
| 970 |
% |
| 971 |
% \subsubsection{From binary number} |
| 972 |
% |
| 973 |
% \begin{macro}{\bitsetSetBin} |
| 974 |
% \begin{macrocode} |
| 975 |
\def\bitsetSetBin#1#2{% |
| 976 |
\edef\BitSet@Temp{#2}% |
| 977 |
\edef\BitSet@Temp{% |
| 978 |
\expandafter\expandafter\expandafter\BitSet@ZapSpace |
| 979 |
\expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty |
| 980 |
}% |
| 981 |
\edef\BitSet@Temp{% |
| 982 |
\expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty |
| 983 |
}% |
| 984 |
\ifx\BitSet@Temp\BitSet@Empty |
| 985 |
\expandafter\let\csname BS@#1\endcsname\BitSet@Zero |
| 986 |
\else |
| 987 |
\expandafter\edef\csname BS@#1\endcsname{% |
| 988 |
\expandafter\BitSet@Reverse\BitSet@Temp!% |
| 989 |
}% |
| 990 |
\fi |
| 991 |
} |
| 992 |
% \end{macrocode} |
| 993 |
% \end{macro} |
| 994 |
% \begin{macro}{\BitSet@KillZeros} |
| 995 |
% \begin{macrocode} |
| 996 |
\def\BitSet@KillZeros#1{% |
| 997 |
\ifx#10% |
| 998 |
\expandafter\BitSet@KillZeros |
| 999 |
\else |
| 1000 |
#1% |
| 1001 |
\fi |
| 1002 |
} |
| 1003 |
% \end{macrocode} |
| 1004 |
% \end{macro} |
| 1005 |
% \begin{macro}{\BitSet@Reverse} |
| 1006 |
% \begin{macrocode} |
| 1007 |
\def\BitSet@Reverse#1#2!{% |
| 1008 |
\ifx\\#2\\% |
| 1009 |
#1% |
| 1010 |
\else |
| 1011 |
\BitSet@AfterFi{% |
| 1012 |
\BitSet@Reverse#2!#1% |
| 1013 |
}% |
| 1014 |
\BitSet@Fi |
| 1015 |
} |
| 1016 |
% \end{macrocode} |
| 1017 |
% \end{macro} |
| 1018 |
% |
| 1019 |
% \subsubsection{From octal/hex number} |
| 1020 |
% |
| 1021 |
% \begin{macro}{\bitsetSetOct} |
| 1022 |
% \begin{macrocode} |
| 1023 |
\def\bitsetSetOct{% |
| 1024 |
\BitSet@SetOctHex\BitSet@FromFirstOct |
| 1025 |
} |
| 1026 |
% \end{macrocode} |
| 1027 |
% \end{macro} |
| 1028 |
% \begin{macro}{\bitsetSetHex} |
| 1029 |
% \begin{macrocode} |
| 1030 |
\def\bitsetSetHex{% |
| 1031 |
\BitSet@SetOctHex\BitSet@FromFirstHex |
| 1032 |
} |
| 1033 |
% \end{macrocode} |
| 1034 |
% \end{macro} |
| 1035 |
% \begin{macro}{\BitSet@SetOctHex} |
| 1036 |
% \begin{macrocode} |
| 1037 |
\def\BitSet@SetOctHex#1#2#3{% |
| 1038 |
\edef\BitSet@Temp{#3}% |
| 1039 |
\edef\BitSet@Temp{% |
| 1040 |
\expandafter\expandafter\expandafter\BitSet@ZapSpace |
| 1041 |
\expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty |
| 1042 |
}% |
| 1043 |
\edef\BitSet@Temp{% |
| 1044 |
\expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty |
| 1045 |
}% |
| 1046 |
\ifx\BitSet@Temp\BitSet@Empty |
| 1047 |
\expandafter\let\csname BS@#2\endcsname\BitSet@Zero |
| 1048 |
\else |
| 1049 |
\edef\BitSet@Temp{% |
| 1050 |
\expandafter#1\BitSet@Temp!% |
| 1051 |
}% |
| 1052 |
\ifx\BitSet@Temp\BitSet@Empty |
| 1053 |
\expandafter\let\csname BS@#2\endcsname\BitSet@Zero |
| 1054 |
\else |
| 1055 |
\expandafter\edef\csname BS@#2\endcsname{% |
| 1056 |
\expandafter\BitSet@Reverse\BitSet@Temp!% |
| 1057 |
}% |
| 1058 |
\fi |
| 1059 |
\fi |
| 1060 |
} |
| 1061 |
% \end{macrocode} |
| 1062 |
% \end{macro} |
| 1063 |
% \begin{macro}{\BitSet@FromFirstOct} |
| 1064 |
% \begin{macrocode} |
| 1065 |
\def\BitSet@FromFirstOct#1{% |
| 1066 |
\ifx#1!% |
| 1067 |
\else |
| 1068 |
\ifcase#1 \BitSet@AfterFiFi\BitSet@FromFirstOct |
| 1069 |
\or 1% |
| 1070 |
\or 10% |
| 1071 |
\or 11% |
| 1072 |
\or 100% |
| 1073 |
\or 101% |
| 1074 |
\or 110% |
| 1075 |
\or 111% |
| 1076 |
\else \BitSetError:WrongOctalDigit% |
| 1077 |
\fi |
| 1078 |
\expandafter\BitSet@FromOct |
| 1079 |
\BitSet@Fi |
| 1080 |
} |
| 1081 |
% \end{macrocode} |
| 1082 |
% \end{macro} |
| 1083 |
% \begin{macro}{\BitSet@FromOct} |
| 1084 |
% \begin{macrocode} |
| 1085 |
\def\BitSet@FromOct#1{% |
| 1086 |
\ifx#1!% |
| 1087 |
\else |
| 1088 |
\ifcase#1 000% |
| 1089 |
\or 001% |
| 1090 |
\or 010% |
| 1091 |
\or 011% |
| 1092 |
\or 100% |
| 1093 |
\or 101% |
| 1094 |
\or 110% |
| 1095 |
\or 111% |
| 1096 |
\else \BitSetError:WrongOctalDigit% |
| 1097 |
\fi |
| 1098 |
\expandafter\BitSet@FromOct |
| 1099 |
\fi |
| 1100 |
} |
| 1101 |
% \end{macrocode} |
| 1102 |
% \end{macro} |
| 1103 |
% |
| 1104 |
% \begin{macro}{\BitSet@FromFirstHex} |
| 1105 |
% \begin{macrocode} |
| 1106 |
\def\BitSet@FromFirstHex#1{% |
| 1107 |
\ifx#1!% |
| 1108 |
\else |
| 1109 |
\ifx#10% |
| 1110 |
\BitSet@AfterFiFi\BitSet@FromFirstHex |
| 1111 |
\fi |
| 1112 |
\expandafter\ifx\csname BitSet@Hex#1\endcsname\relax |
| 1113 |
\BitSetError:InvalidHexDigit% |
| 1114 |
\else |
| 1115 |
\expandafter\expandafter\expandafter\BitSet@KillZeros |
| 1116 |
\csname BitSet@Hex#1\endcsname |
| 1117 |
\fi |
| 1118 |
\expandafter\BitSet@FromHex |
| 1119 |
\BitSet@Fi |
| 1120 |
} |
| 1121 |
% \end{macrocode} |
| 1122 |
% \end{macro} |
| 1123 |
% \begin{macro}{\BitSet@FromHex} |
| 1124 |
% \begin{macrocode} |
| 1125 |
\def\BitSet@FromHex#1{% |
| 1126 |
\ifx#1!% |
| 1127 |
\else |
| 1128 |
\expandafter\ifx\csname BitSet@Hex#1\endcsname\relax |
| 1129 |
\BitSetError:InvalidHexDigit% |
| 1130 |
\else |
| 1131 |
\csname BitSet@Hex#1\endcsname |
| 1132 |
\fi |
| 1133 |
\expandafter\BitSet@FromHex |
| 1134 |
\fi |
| 1135 |
} |
| 1136 |
% \end{macrocode} |
| 1137 |
% \end{macro} |
| 1138 |
% \begin{macro}{\BitSet@Hex[0..F]} |
| 1139 |
% \begin{macrocode} |
| 1140 |
\def\BitSet@Temp#1{% |
| 1141 |
\expandafter\def\csname BitSet@Hex#1\endcsname |
| 1142 |
} |
| 1143 |
\BitSet@Temp 0{0000}% |
| 1144 |
\BitSet@Temp 1{0001}% |
| 1145 |
\BitSet@Temp 2{0010}% |
| 1146 |
\BitSet@Temp 3{0011}% |
| 1147 |
\BitSet@Temp 4{0100}% |
| 1148 |
\BitSet@Temp 5{0101}% |
| 1149 |
\BitSet@Temp 6{0110}% |
| 1150 |
\BitSet@Temp 7{0111}% |
| 1151 |
\BitSet@Temp 8{1000}% |
| 1152 |
\BitSet@Temp 9{1001}% |
| 1153 |
\BitSet@Temp A{1010}% |
| 1154 |
\BitSet@Temp B{1011}% |
| 1155 |
\BitSet@Temp C{1100}% |
| 1156 |
\BitSet@Temp D{1101}% |
| 1157 |
\BitSet@Temp E{1110}% |
| 1158 |
\BitSet@Temp F{1111}% |
| 1159 |
\BitSet@Temp a{1010}% |
| 1160 |
\BitSet@Temp b{1011}% |
| 1161 |
\BitSet@Temp c{1100}% |
| 1162 |
\BitSet@Temp d{1101}% |
| 1163 |
\BitSet@Temp e{1110}% |
| 1164 |
\BitSet@Temp f{1111}% |
| 1165 |
% \end{macrocode} |
| 1166 |
% \end{macro} |
| 1167 |
% |
| 1168 |
% \subsubsection{From decimal number} |
| 1169 |
% |
| 1170 |
% \begin{macro}{\bitsetSetDec} |
| 1171 |
% \begin{macrocode} |
| 1172 |
\def\bitsetSetDec#1#2{% |
| 1173 |
\edef\BitSet@Temp{#2}% |
| 1174 |
\edef\BitSet@Temp{% |
| 1175 |
\expandafter\expandafter\expandafter\BitSet@ZapSpace |
| 1176 |
\expandafter\BitSet@Temp\BitSet@Space\BitSet@Empty |
| 1177 |
}% |
| 1178 |
\edef\BitSet@Temp{% |
| 1179 |
\expandafter\BitSet@KillZeros\BitSet@Temp\BitSet@Empty |
| 1180 |
}% |
| 1181 |
\ifx\BitSet@Temp\BitSet@Empty |
| 1182 |
\expandafter\let\csname BS@#1\endcsname\BitSet@Zero |
| 1183 |
\else |
| 1184 |
\ifcase\bigintcalcSgn{\BitSet@Temp} % |
| 1185 |
\expandafter\let\csname BS@#1\endcsname\BitSet@Zero |
| 1186 |
\or |
| 1187 |
\ifnum\bigintcalcCmp\BitSet@Temp\BitSet@MaxSize>0 % |
| 1188 |
\expandafter\edef\csname BS@#1\endcsname{% |
| 1189 |
\expandafter\BitSet@SetDecBig\BitSet@Temp!% |
| 1190 |
}% |
| 1191 |
\else |
| 1192 |
\expandafter\edef\csname BS@#1\endcsname{% |
| 1193 |
\expandafter\BitSet@SetDec\BitSet@Temp!% |
| 1194 |
}% |
| 1195 |
\fi |
| 1196 |
\else |
| 1197 |
\@PackageError{bitset}{% |
| 1198 |
Bit sets cannot be negative% |
| 1199 |
}\@ehc |
| 1200 |
\fi |
| 1201 |
\fi |
| 1202 |
} |
| 1203 |
% \end{macrocode} |
| 1204 |
% \end{macro} |
| 1205 |
% \begin{macro}{\BitSet@SetDecBig} |
| 1206 |
% \begin{macrocode} |
| 1207 |
\def\BitSet@SetDecBig#1#2#3#4#5#6#7#8#9!{% |
| 1208 |
\ifx\\#9\\% |
| 1209 |
\BitSet@SetDec#1#2#3#4#5#6#7#8!% |
| 1210 |
\else |
| 1211 |
\ifcase\BigIntCalcOdd#1#2#4#5#6#7#8#9! % |
| 1212 |
0% |
| 1213 |
\or |
| 1214 |
1% |
| 1215 |
? \else\BitSetError:ThisCannotHappen% |
| 1216 |
\fi |
| 1217 |
\BitSet@AfterFi{% |
| 1218 |
\expandafter\expandafter\expandafter\BitSet@SetDecBig |
| 1219 |
\BigIntCalcShr#1#2#3#4#5#6#7#8#9!!% |
| 1220 |
}% |
| 1221 |
\BitSet@Fi |
| 1222 |
} |
| 1223 |
% \end{macrocode} |
| 1224 |
% \end{macro} |
| 1225 |
% \begin{macro}{\BitSet@SetDec} |
| 1226 |
% \begin{macrocode} |
| 1227 |
\def\BitSet@SetDec#1!{% |
| 1228 |
\ifcase#1 % |
| 1229 |
\or 1% |
| 1230 |
\else |
| 1231 |
\ifodd#1 % |
| 1232 |
1% |
| 1233 |
\else |
| 1234 |
0% |
| 1235 |
\fi |
| 1236 |
\BitSet@AfterFi{% |
| 1237 |
\expandafter\expandafter\expandafter\BitSet@SetDec |
| 1238 |
\IntCalcShr#1!!% |
| 1239 |
}% |
| 1240 |
\BitSet@Fi |
| 1241 |
} |
| 1242 |
% \end{macrocode} |
| 1243 |
% \end{macro} |
| 1244 |
% |
| 1245 |
% \subsection{Export}\label{src:export} |
| 1246 |
% |
| 1247 |
% \subsubsection{To binary number} |
| 1248 |
% |
| 1249 |
% \begin{macro}{\bitsetGetBin} |
| 1250 |
% \begin{macrocode} |
| 1251 |
\def\bitsetGetBin#1#2{% |
| 1252 |
\romannumeral0% |
| 1253 |
\expandafter\expandafter\expandafter\BitSet@@GetBin |
| 1254 |
\intcalcNum{#2}!{#1}% |
| 1255 |
} |
| 1256 |
% \end{macrocode} |
| 1257 |
% \end{macro} |
| 1258 |
% \begin{macro}{\BitSet@@GetBin} |
| 1259 |
% \begin{macrocode} |
| 1260 |
\def\BitSet@@GetBin#1!#2{% |
| 1261 |
\BitSet@IfUndefined{#2}{% |
| 1262 |
\ifnum#1>1 % |
| 1263 |
\BitSet@AfterFi{% |
| 1264 |
\expandafter\expandafter\expandafter\BitSet@Fill |
| 1265 |
\IntCalcDec#1!!0% |
| 1266 |
}% |
| 1267 |
\else |
| 1268 |
\BitSet@AfterFi{ 0}% |
| 1269 |
\BitSet@Fi |
| 1270 |
}{% |
| 1271 |
\expandafter\expandafter\expandafter\BitSet@NumBinRev |
| 1272 |
\expandafter\expandafter\expandafter1% |
| 1273 |
\expandafter\expandafter\expandafter!% |
| 1274 |
\csname BS@#2\endcsname!!#1!% |
| 1275 |
}% |
| 1276 |
} |
| 1277 |
% \end{macrocode} |
| 1278 |
% \end{macro} |
| 1279 |
% \begin{macro}{\BitSet@Fill} |
| 1280 |
% |#1|: number of leading digits |0|\\ |
| 1281 |
% |#2|: result |
| 1282 |
% \begin{macrocode} |
| 1283 |
\def\BitSet@Fill#1!{% |
| 1284 |
\ifnum#1>0 % |
| 1285 |
\BitSet@AfterFi{% |
| 1286 |
\expandafter\expandafter\expandafter\BitSet@Fill |
| 1287 |
\IntCalcDec#1!!0% |
| 1288 |
}% |
| 1289 |
\else |
| 1290 |
\BitSet@AfterFi{ }% |
| 1291 |
\BitSet@Fi |
| 1292 |
} |
| 1293 |
% \end{macrocode} |
| 1294 |
% \end{macro} |
| 1295 |
% |
| 1296 |
% \begin{macro}{\BitSet@NumBinRev} |
| 1297 |
% |#1|: bit counter (including |#2|)\\ |
| 1298 |
% |#2#3|: reverted number\\ |
| 1299 |
% |#4|: result\\ |
| 1300 |
% |#5|: min size |
| 1301 |
% \begin{macrocode} |
| 1302 |
\def\BitSet@NumBinRev#1!#2#3!{% |
| 1303 |
\ifx\\#3\\% |
| 1304 |
\BitSet@AfterFi{% |
| 1305 |
\BitSet@NumBinFill#1!#2% |
| 1306 |
}% |
| 1307 |
\else |
| 1308 |
\BitSet@AfterFi{% |
| 1309 |
\expandafter\expandafter\expandafter\BitSet@NumBinRev |
| 1310 |
\IntCalcInc#1!!#3!#2% |
| 1311 |
}% |
| 1312 |
\BitSet@Fi |
| 1313 |
} |
| 1314 |
% \end{macrocode} |
| 1315 |
% \end{macro} |
| 1316 |
% \begin{macro}{\BitSet@NumBinFill} |
| 1317 |
% \begin{macrocode} |
| 1318 |
\def\BitSet@NumBinFill#1!#2!#3!{% |
| 1319 |
\ifnum#3>#1 % |
| 1320 |
\BitSet@AfterFi{% |
| 1321 |
\expandafter\expandafter\expandafter\BitSet@Fill |
| 1322 |
\IntCalcSub#3!#1!!#2% |
| 1323 |
}% |
| 1324 |
\else |
| 1325 |
\BitSet@AfterFi{ #2}% |
| 1326 |
\BitSet@Fi |
| 1327 |
} |
| 1328 |
% \end{macrocode} |
| 1329 |
% \end{macro} |
| 1330 |
% |
| 1331 |
% \subsubsection{To octal/hexadecimal number} |
| 1332 |
% |
| 1333 |
% \begin{macro}{\bitsetGetOct} |
| 1334 |
% \begin{macrocode} |
| 1335 |
\def\bitsetGetOct#1#2{% |
| 1336 |
\romannumeral0% |
| 1337 |
\bitsetIsEmpty{#1}{% |
| 1338 |
\expandafter\expandafter\expandafter\BitSet@@GetOctHex |
| 1339 |
\intcalcNum{#2}!3!230% |
| 1340 |
}{% |
| 1341 |
\expandafter\expandafter\expandafter\BitSet@@GetOct |
| 1342 |
\expandafter\expandafter\expandafter1% |
| 1343 |
\expandafter\expandafter\expandafter!% |
| 1344 |
\expandafter\expandafter\expandafter!% |
| 1345 |
\csname BS@#1\endcsname00% |
| 1346 |
\BitSet@Empty\BitSet@Empty\BitSet@Empty!{#2}% |
| 1347 |
}% |
| 1348 |
} |
| 1349 |
% \end{macrocode} |
| 1350 |
% \end{macro} |
| 1351 |
% \begin{macro}{\bitsetGetHex} |
| 1352 |
% \begin{macrocode} |
| 1353 |
\def\bitsetGetHex#1#2{% |
| 1354 |
\romannumeral0% |
| 1355 |
\bitsetIsEmpty{#1}{% |
| 1356 |
\expandafter\expandafter\expandafter\BitSet@@GetOctHex |
| 1357 |
\intcalcNum{#2}!4!340% |
| 1358 |
}{% |
| 1359 |
\expandafter\expandafter\expandafter\BitSet@@GetHex |
| 1360 |
\expandafter\expandafter\expandafter1% |
| 1361 |
\expandafter\expandafter\expandafter!% |
| 1362 |
\expandafter\expandafter\expandafter!% |
| 1363 |
\csname BS@#1\endcsname000% |
| 1364 |
\BitSet@Empty\BitSet@Empty\BitSet@Empty\BitSet@Empty!{#2}% |
| 1365 |
}% |
| 1366 |
} |
| 1367 |
% \end{macrocode} |
| 1368 |
% \end{macro} |
| 1369 |
% \begin{macro}{\BitSet@@GetOct} |
| 1370 |
% |#1|: number of digits\\ |
| 1371 |
% |#2|: result\\ |
| 1372 |
% |#3#4#5|: bits |
| 1373 |
% \begin{macrocode} |
| 1374 |
\def\BitSet@@GetOct#1!#2!#3#4#5{% |
| 1375 |
\ifx#5\BitSet@Empty |
| 1376 |
\BitSet@AfterFi{% |
| 1377 |
\expandafter\expandafter\expandafter\BitSet@GetOctHex |
| 1378 |
\IntCalcDec#1!!#2!23% |
| 1379 |
}% |
| 1380 |
\else |
| 1381 |
\BitSet@AfterFi{% |
| 1382 |
\expandafter\expandafter\expandafter\BitSet@@GetOct |
| 1383 |
\number\IntCalcInc#1!\expandafter\expandafter\expandafter!% |
| 1384 |
\csname BitSet@Oct#5#4#3\endcsname#2!% |
| 1385 |
}% |
| 1386 |
\BitSet@Fi |
| 1387 |
} |
| 1388 |
% \end{macrocode} |
| 1389 |
% \end{macro} |
| 1390 |
% \begin{macro}{\BitSet@Oct[000..111]} |
| 1391 |
% \begin{macrocode} |
| 1392 |
\def\BitSet@Temp#1#2#3#4{% |
| 1393 |
\expandafter\def\csname BitSet@Oct#1#2#3\endcsname{#4}% |
| 1394 |
} |
| 1395 |
\BitSet@Temp0000% |
| 1396 |
\BitSet@Temp0011% |
| 1397 |
\BitSet@Temp0102% |
| 1398 |
\BitSet@Temp0113% |
| 1399 |
\BitSet@Temp1004% |
| 1400 |
\BitSet@Temp1015% |
| 1401 |
\BitSet@Temp1106% |
| 1402 |
\BitSet@Temp1117% |
| 1403 |
% \end{macrocode} |
| 1404 |
% \end{macro} |
| 1405 |
% \begin{macro}{\BitSet@@GetHex} |
| 1406 |
% |#1|: number of digits\\ |
| 1407 |
% |#2|: result\\ |
| 1408 |
% |#3#4#5#6|: bits |
| 1409 |
% \begin{macrocode} |
| 1410 |
\def\BitSet@@GetHex#1!#2!#3#4#5#6{% |
| 1411 |
\ifx#6\BitSet@Empty |
| 1412 |
\BitSet@AfterFi{% |
| 1413 |
\expandafter\expandafter\expandafter\BitSet@GetOctHex |
| 1414 |
\IntCalcDec#1!!#2!34% |
| 1415 |
}% |
| 1416 |
\else |
| 1417 |
\BitSet@AfterFi{% |
| 1418 |
\expandafter\expandafter\expandafter\BitSet@@GetHex |
| 1419 |
\number\IntCalcInc#1!\expandafter\expandafter\expandafter!% |
| 1420 |
\csname BitSet@Hex#6#5#4#3\endcsname#2!% |
| 1421 |
}% |
| 1422 |
\BitSet@Fi |
| 1423 |
} |
| 1424 |
% \end{macrocode} |
| 1425 |
% \end{macro} |
| 1426 |
% \begin{macro}{\BitSet@Hex[0000..1111]} |
| 1427 |
% \begin{macrocode} |
| 1428 |
\def\BitSet@Temp#1#2#3#4#5{% |
| 1429 |
\expandafter\def\csname BitSet@Hex#1#2#3#4\endcsname{#5}% |
| 1430 |
} |
| 1431 |
\BitSet@Temp00000% |
| 1432 |
\BitSet@Temp00011% |
| 1433 |
\BitSet@Temp00102% |
| 1434 |
\BitSet@Temp00113% |
| 1435 |
\BitSet@Temp01004% |
| 1436 |
\BitSet@Temp01015% |
| 1437 |
\BitSet@Temp01106% |
| 1438 |
\BitSet@Temp01117% |
| 1439 |
\BitSet@Temp10008% |
| 1440 |
\BitSet@Temp10019% |
| 1441 |
\BitSet@Temp1010A% |
| 1442 |
\BitSet@Temp1011B% |
| 1443 |
\BitSet@Temp1100C% |
| 1444 |
\BitSet@Temp1101D% |
| 1445 |
\BitSet@Temp1110E% |
| 1446 |
\BitSet@Temp1111F% |
| 1447 |
% \end{macrocode} |
| 1448 |
% \end{macro} |
| 1449 |
% \begin{macro}{\BitSet@GetOctHex} |
| 1450 |
% Leading zeros $ (|#4| - |#1| * 3 + 2)/3 $ if $ |#4| > |#1| * 3$\\ |
| 1451 |
% |#1|: digit size\\ |
| 1452 |
% |#2|: result\\ |
| 1453 |
% |#3|: bits per digit - 1\\ |
| 1454 |
% |#4|: bits per digit |
| 1455 |
% |#5|: garbage\\ |
| 1456 |
% |#6|: min size |
| 1457 |
% \begin{macrocode} |
| 1458 |
\def\BitSet@GetOctHex#1!#2!#3#4#5!#6{% |
| 1459 |
\expandafter\BitSet@@GetOctHex |
| 1460 |
\number\intcalcNum{#6}\expandafter\expandafter\expandafter!% |
| 1461 |
\IntCalcMul#1!#4!!#3#4#2% |
| 1462 |
} |
| 1463 |
% \end{macrocode} |
| 1464 |
% \end{macro} |
| 1465 |
% \begin{macro}{\BitSet@@GetOctHex} |
| 1466 |
% |#1|: plain min size\\ |
| 1467 |
% |#2|: digits * (bits per digit)\\ |
| 1468 |
% |#3|: bits per digit - 1\\ |
| 1469 |
% |#4|: bits per digit |
| 1470 |
% \begin{macrocode} |
| 1471 |
\def\BitSet@@GetOctHex#1!#2!#3#4{% |
| 1472 |
\ifnum#1>#2 % |
| 1473 |
\BitSet@AfterFi{% |
| 1474 |
\expandafter\expandafter\expandafter\expandafter |
| 1475 |
\expandafter\expandafter\expandafter\BitSet@Fill |
| 1476 |
\expandafter\IntCalcDiv\number |
| 1477 |
\expandafter\expandafter\expandafter\IntCalcAdd |
| 1478 |
\IntCalcSub#1!#2!!#3!!#4!!% |
| 1479 |
}% |
| 1480 |
\else |
| 1481 |
\BitSet@AfterFi{ }% |
| 1482 |
\BitSet@Fi |
| 1483 |
} |
| 1484 |
% \end{macrocode} |
| 1485 |
% \end{macro} |
| 1486 |
% |
| 1487 |
% \subsubsection{To decimal number} |
| 1488 |
% |
| 1489 |
% \begin{macro}{\bitsetGetDec} |
| 1490 |
% \begin{macrocode} |
| 1491 |
\def\bitsetGetDec#1{% |
| 1492 |
\romannumeral0% |
| 1493 |
\BitSet@IfUndefined{#1}{ 0}{% |
| 1494 |
\expandafter\expandafter\expandafter\BitSet@GetDec |
| 1495 |
\csname BS@#1\endcsname!% |
| 1496 |
}% |
| 1497 |
} |
| 1498 |
% \end{macrocode} |
| 1499 |
% \end{macro} |
| 1500 |
% \begin{macro}{\BitSet@GetDec} |
| 1501 |
% \begin{macrocode} |
| 1502 |
\def\BitSet@GetDec#1#2!{% |
| 1503 |
\ifx\\#2\\% |
| 1504 |
\BitSet@AfterFi{ #1}% |
| 1505 |
\else |
| 1506 |
\BitSet@AfterFi{% |
| 1507 |
\BitSet@@GetDec2!#1!#2!% |
| 1508 |
}% |
| 1509 |
\BitSet@Fi |
| 1510 |
} |
| 1511 |
% \end{macrocode} |
| 1512 |
% \end{macro} |
| 1513 |
% \begin{macro}{\BitSet@@GetDec} |
| 1514 |
% |#1|: power of two\\ |
| 1515 |
% |#2|: result\\ |
| 1516 |
% |#3#4|: number |
| 1517 |
% \begin{macrocode} |
| 1518 |
\def\BitSet@@GetDec#1!#2!#3#4!{% |
| 1519 |
\ifx\\#4\\% |
| 1520 |
\ifx#31% |
| 1521 |
\BitSet@AfterFiFi{% |
| 1522 |
\expandafter\expandafter\expandafter\BitSet@Space |
| 1523 |
\IntCalcAdd#1!#2!% |
| 1524 |
}% |
| 1525 |
\else |
| 1526 |
\BitSet@AfterFiFi{ #2}% |
| 1527 |
\fi |
| 1528 |
\else |
| 1529 |
\ifx#31% |
| 1530 |
\BitSet@AfterFiFi{% |
| 1531 |
\csname BitSet@N#1% |
| 1532 |
\expandafter\expandafter\expandafter\endcsname |
| 1533 |
\IntCalcAdd#1!#2!!#4!% |
| 1534 |
}% |
| 1535 |
\else |
| 1536 |
\BitSet@AfterFiFi{% |
| 1537 |
\csname BitSet@N#1\endcsname#2!#4!% |
| 1538 |
}% |
| 1539 |
\fi |
| 1540 |
\BitSet@Fi |
| 1541 |
} |
| 1542 |
% \end{macrocode} |
| 1543 |
% \end{macro} |
| 1544 |
% \begin{macro}{\BitSet@N[1,2,4,...]} |
| 1545 |
% \begin{macrocode} |
| 1546 |
\def\BitSet@Temp#1#2{% |
| 1547 |
\expandafter\def\csname BitSet@N#1\endcsname{% |
| 1548 |
\BitSet@@GetDec#2!% |
| 1549 |
}% |
| 1550 |
} |
| 1551 |
\BitSet@Temp{1}{2} |
| 1552 |
\BitSet@Temp{2}{4} |
| 1553 |
\BitSet@Temp{4}{8} |
| 1554 |
\BitSet@Temp{8}{16} |
| 1555 |
\BitSet@Temp{16}{32} |
| 1556 |
\BitSet@Temp{32}{64} |
| 1557 |
\BitSet@Temp{64}{128} |
| 1558 |
\BitSet@Temp{128}{256} |
| 1559 |
\BitSet@Temp{256}{512} |
| 1560 |
\BitSet@Temp{512}{1024} |
| 1561 |
\BitSet@Temp{1024}{2048} |
| 1562 |
\BitSet@Temp{2048}{4096} |
| 1563 |
\BitSet@Temp{4096}{8192} |
| 1564 |
\BitSet@Temp{8192}{16384} |
| 1565 |
\BitSet@Temp{16384}{32768} |
| 1566 |
\BitSet@Temp{32768}{65536} |
| 1567 |
\BitSet@Temp{65536}{131072} |
| 1568 |
\BitSet@Temp{131072}{262144} |
| 1569 |
\BitSet@Temp{262144}{524288} |
| 1570 |
\BitSet@Temp{524288}{1048576} |
| 1571 |
\BitSet@Temp{1048576}{2097152} |
| 1572 |
\BitSet@Temp{2097152}{4194304} |
| 1573 |
\BitSet@Temp{4194304}{8388608} |
| 1574 |
\BitSet@Temp{8388608}{16777216} |
| 1575 |
\BitSet@Temp{16777216}{33554432} |
| 1576 |
\BitSet@Temp{33554432}{67108864} |
| 1577 |
\BitSet@Temp{67108864}{134217728} |
| 1578 |
\BitSet@Temp{134217728}{268435456} |
| 1579 |
\BitSet@Temp{268435456}{536870912} |
| 1580 |
\BitSet@Temp{536870912}{1073741824} |
| 1581 |
% \end{macrocode} |
| 1582 |
% \end{macro} |
| 1583 |
% \begin{macro}{\BitSet@N1073741824} |
| 1584 |
% \begin{macrocode} |
| 1585 |
\expandafter\def\csname BitSet@N1073741824\endcsname{% |
| 1586 |
\BitSet@GetDecBig2147483648!% |
| 1587 |
}% |
| 1588 |
% \end{macrocode} |
| 1589 |
% \end{macro} |
| 1590 |
% |
| 1591 |
% \begin{macro}{\BitSet@GetDecBig} |
| 1592 |
% |#1|: current power of two\\ |
| 1593 |
% |#2|: result\\ |
| 1594 |
% |#3#4|: number |
| 1595 |
% \begin{macrocode} |
| 1596 |
\def\BitSet@GetDecBig#1!#2!#3#4!{% |
| 1597 |
\ifx\\#4\\% |
| 1598 |
\ifx#31% |
| 1599 |
\BitSet@AfterFiFi{% |
| 1600 |
\expandafter\expandafter\expandafter\BitSet@Space |
| 1601 |
\BigIntCalcAdd#1!#2!% |
| 1602 |
}% |
| 1603 |
\else |
| 1604 |
\BitSet@AfterFiFi{ #2}% |
| 1605 |
\fi |
| 1606 |
\else |
| 1607 |
\ifx#31% |
| 1608 |
\BitSet@AfterFiFi{% |
| 1609 |
\expandafter\expandafter\expandafter\BitSet@@GetDecBig |
| 1610 |
\BigIntCalcAdd#1!#2!!#1!#4!% |
| 1611 |
}% |
| 1612 |
\else |
| 1613 |
\BitSet@AfterFiFi{% |
| 1614 |
\expandafter\expandafter\expandafter\BitSet@GetDecBig |
| 1615 |
\BigIntCalcShl#1!!#2!#4!% |
| 1616 |
}% |
| 1617 |
\fi |
| 1618 |
\BitSet@Fi |
| 1619 |
} |
| 1620 |
% \end{macrocode} |
| 1621 |
% \end{macro} |
| 1622 |
% \begin{macro}{\BitSet@@GetDecBig} |
| 1623 |
% |#1|: result\\ |
| 1624 |
% |#2|: power of two\\ |
| 1625 |
% |#3#4|: number |
| 1626 |
% \begin{macrocode} |
| 1627 |
\def\BitSet@@GetDecBig#1!#2!{% |
| 1628 |
\expandafter\expandafter\expandafter\BitSet@GetDecBig |
| 1629 |
\BigIntCalcShl#2!!#1!% |
| 1630 |
} |
| 1631 |
% \end{macrocode} |
| 1632 |
% \end{macro} |
| 1633 |
% |
| 1634 |
% \subsection{Logical operators}\label{src:log} |
| 1635 |
% |
| 1636 |
% \subsubsection{\cs{bitsetAnd}} |
| 1637 |
% |
| 1638 |
% \begin{macro}{\bitsetAnd} |
| 1639 |
% Decision table for \cs{bitsetAnd}: |
| 1640 |
% \begin{quote} |
| 1641 |
% \begin{tabular}{l|l|l|l|} |
| 1642 |
% & undef(B) & empty(B) & cardinality(B)$>$0\\ |
| 1643 |
% \hline |
| 1644 |
% undef(A) & A := empty & A := empty & A := empty\\ |
| 1645 |
% \hline |
| 1646 |
% empty(A) & & &\\ |
| 1647 |
% \hline |
| 1648 |
% cardinality(A)$>$0 & A := empty & A := empty & A \&= B\\ |
| 1649 |
% \hline |
| 1650 |
% \end{tabular} |
| 1651 |
% \end{quote} |
| 1652 |
% \begin{macrocode} |
| 1653 |
\def\bitsetAnd#1#2{% |
| 1654 |
\bitsetIsEmpty{#1}{% |
| 1655 |
\bitsetReset{#1}% |
| 1656 |
}{% |
| 1657 |
\bitsetIsEmpty{#2}{% |
| 1658 |
\bitsetReset{#1}% |
| 1659 |
}{% |
| 1660 |
\expandafter\edef\csname BS@#1\endcsname{% |
| 1661 |
\expandafter\expandafter\expandafter\BitSet@And |
| 1662 |
\csname BS@#1\expandafter\expandafter\expandafter\endcsname |
| 1663 |
\expandafter\expandafter\expandafter!% |
| 1664 |
\csname BS@#2\endcsname!!% |
| 1665 |
}% |
| 1666 |
\expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty |
| 1667 |
\bitsetReset{#1}% |
| 1668 |
\fi |
| 1669 |
}% |
| 1670 |
}% |
| 1671 |
} |
| 1672 |
% \end{macrocode} |
| 1673 |
% \end{macro} |
| 1674 |
% \begin{macro}{\BitSet@And} |
| 1675 |
% \begin{macrocode} |
| 1676 |
\def\BitSet@And#1#2!#3#4!#5!{% |
| 1677 |
\ifx\\#2\\% |
| 1678 |
\ifnum#1#3=11 #51\fi |
| 1679 |
\else |
| 1680 |
\ifx\\#4\\% |
| 1681 |
\ifnum#1#3=11 #51\fi |
| 1682 |
\else |
| 1683 |
\ifnum#1#3=11 % |
| 1684 |
#51% |
| 1685 |
\BitSet@AfterFiFiFi{% |
| 1686 |
\BitSet@And#2!#4!!% |
| 1687 |
}% |
| 1688 |
\else |
| 1689 |
\BitSet@AfterFiFiFi{% |
| 1690 |
\BitSet@And#2!#4!#50!% |
| 1691 |
}% |
| 1692 |
\fi |
| 1693 |
\fi |
| 1694 |
\BitSet@Fi |
| 1695 |
} |
| 1696 |
% \end{macrocode} |
| 1697 |
% \end{macro} |
| 1698 |
% |
| 1699 |
% \subsubsection{\cs{bitsetAndNot}} |
| 1700 |
% |
| 1701 |
% \begin{macro}{\bitsetAndNot} |
| 1702 |
% Decision table for \cs{bitsetAndNot}: |
| 1703 |
% \begin{quote} |
| 1704 |
% \begin{tabular}{l|l|l|l|} |
| 1705 |
% & undef(B) & empty(B) & cardinality(B)$>$0\\ |
| 1706 |
% \hline |
| 1707 |
% undef(A) & A := empty & A := empty & A := empty\\ |
| 1708 |
% \hline |
| 1709 |
% empty(A) & & &\\ |
| 1710 |
% \hline |
| 1711 |
% cardinality(A)$>$0 & & & A \&= !B\\ |
| 1712 |
% \hline |
| 1713 |
% \end{tabular} |
| 1714 |
% \end{quote} |
| 1715 |
% \begin{macrocode} |
| 1716 |
\def\bitsetAndNot#1#2{% |
| 1717 |
\bitsetIsEmpty{#1}{% |
| 1718 |
\bitsetReset{#1}% |
| 1719 |
}{% |
| 1720 |
\bitsetIsEmpty{#2}{% |
| 1721 |
}{% |
| 1722 |
\expandafter\edef\csname BS@#1\endcsname{% |
| 1723 |
\expandafter\expandafter\expandafter\BitSet@AndNot |
| 1724 |
\csname BS@#1\expandafter\expandafter\expandafter\endcsname |
| 1725 |
\expandafter\expandafter\expandafter!% |
| 1726 |
\csname BS@#2\endcsname!!% |
| 1727 |
}% |
| 1728 |
\expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty |
| 1729 |
\bitsetReset{#1}% |
| 1730 |
\fi |
| 1731 |
}% |
| 1732 |
}% |
| 1733 |
} |
| 1734 |
% \end{macrocode} |
| 1735 |
% \end{macro} |
| 1736 |
% \begin{macro}{\BitSet@AndNot} |
| 1737 |
% \begin{macrocode} |
| 1738 |
\def\BitSet@AndNot#1#2!#3#4!#5!{% |
| 1739 |
\ifx\\#2\\% |
| 1740 |
\ifnum#1#3=10 #51\fi |
| 1741 |
\else |
| 1742 |
\ifx\\#4\\% |
| 1743 |
#5% |
| 1744 |
\ifnum#1#3=10 1\else 0\fi |
| 1745 |
#2% |
| 1746 |
\else |
| 1747 |
\ifnum#1#3=10 % |
| 1748 |
#51% |
| 1749 |
\BitSet@AfterFiFiFi{% |
| 1750 |
\BitSet@AndNot#2!#4!!% |
| 1751 |
}% |
| 1752 |
\else |
| 1753 |
\BitSet@AfterFiFiFi{% |
| 1754 |
\BitSet@AndNot#2!#4!#50!% |
| 1755 |
}% |
| 1756 |
\fi |
| 1757 |
\fi |
| 1758 |
\BitSet@Fi |
| 1759 |
} |
| 1760 |
% \end{macrocode} |
| 1761 |
% \end{macro} |
| 1762 |
% |
| 1763 |
% \subsubsection{\cs{bitsetOr}} |
| 1764 |
% |
| 1765 |
% \begin{macro}{\bitsetOr} |
| 1766 |
% Decision table for \cs{bitsetOr}: |
| 1767 |
% \begin{quote} |
| 1768 |
% \begin{tabular}{l|l|l|l|} |
| 1769 |
% & undef(B) & empty(B) & cardinality(B)$>$0\\ |
| 1770 |
% \hline |
| 1771 |
% undef(A) & A := empty & A := empty & A := B\\ |
| 1772 |
% \hline |
| 1773 |
% empty(A) & & & A := B\\ |
| 1774 |
% \hline |
| 1775 |
% cardinality(A)$>$0 & & & A \string|= B\\ |
| 1776 |
% \hline |
| 1777 |
% \end{tabular} |
| 1778 |
% \end{quote} |
| 1779 |
% \begin{macrocode} |
| 1780 |
\def\bitsetOr#1#2{% |
| 1781 |
\bitsetIsEmpty{#2}{% |
| 1782 |
\BitSet@IfUndefined{#1}{\bitsetReset{#1}}{}% |
| 1783 |
}{% |
| 1784 |
\bitsetIsEmpty{#1}{% |
| 1785 |
\expandafter\let\csname BS@#1\expandafter\endcsname |
| 1786 |
\csname BS@#2\endcsname |
| 1787 |
}{% |
| 1788 |
\expandafter\edef\csname BS@#1\endcsname{% |
| 1789 |
\expandafter\expandafter\expandafter\BitSet@Or |
| 1790 |
\csname BS@#1\expandafter\expandafter\expandafter\endcsname |
| 1791 |
\expandafter\expandafter\expandafter!% |
| 1792 |
\csname BS@#2\endcsname!% |
| 1793 |
}% |
| 1794 |
}% |
| 1795 |
}% |
| 1796 |
} |
| 1797 |
% \end{macrocode} |
| 1798 |
% \end{macro} |
| 1799 |
% \begin{macro}{\BitSet@Or} |
| 1800 |
% \begin{macrocode} |
| 1801 |
\def\BitSet@Or#1#2!#3#4!{% |
| 1802 |
\ifnum#1#3>0 1\else 0\fi |
| 1803 |
\ifx\\#2\\% |
| 1804 |
#4% |
| 1805 |
\else |
| 1806 |
\ifx\\#4\\% |
| 1807 |
#2% |
| 1808 |
\else |
| 1809 |
\BitSet@AfterFiFi{% |
| 1810 |
\BitSet@Or#2!#4!% |
| 1811 |
}% |
| 1812 |
\fi |
| 1813 |
\BitSet@Fi |
| 1814 |
} |
| 1815 |
% \end{macrocode} |
| 1816 |
% \end{macro} |
| 1817 |
% |
| 1818 |
% \subsubsection{\cs{bitsetXor}} |
| 1819 |
% |
| 1820 |
% \begin{macro}{\bitsetXor} |
| 1821 |
% Decision table for \cs{bitsetXor}: |
| 1822 |
% \begin{quote} |
| 1823 |
% \begin{tabular}{l|l|l|l|} |
| 1824 |
% & undef(B) & empty(B) & cardinality(B)$>$0\\ |
| 1825 |
% \hline |
| 1826 |
% undef(A) & A := empty & A := empty & A := B\\ |
| 1827 |
% \hline |
| 1828 |
% empty(A) & & & A := B\\ |
| 1829 |
% \hline |
| 1830 |
% cardinality(A)$>$0 & & & A \string^= B\\ |
| 1831 |
% \hline |
| 1832 |
% \end{tabular} |
| 1833 |
% \end{quote} |
| 1834 |
% \begin{macrocode} |
| 1835 |
\def\bitsetXor#1#2{% |
| 1836 |
\bitsetIsEmpty{#2}{% |
| 1837 |
\BitSet@IfUndefined{#1}{\bitsetReset{#1}}{}% |
| 1838 |
}{% |
| 1839 |
\bitsetIsEmpty{#1}{% |
| 1840 |
\expandafter\let\csname BS@#1\expandafter\endcsname |
| 1841 |
\csname BS@#2\endcsname |
| 1842 |
}{% |
| 1843 |
\expandafter\edef\csname BS@#1\endcsname{% |
| 1844 |
\expandafter\expandafter\expandafter\BitSet@Xor |
| 1845 |
\csname BS@#1\expandafter\expandafter\expandafter\endcsname |
| 1846 |
\expandafter\expandafter\expandafter!% |
| 1847 |
\csname BS@#2\endcsname!!% |
| 1848 |
}% |
| 1849 |
\expandafter\ifx\csname BS@#1\endcsname\BitSet@Empty |
| 1850 |
\bitsetReset{#1}% |
| 1851 |
\fi |
| 1852 |
}% |
| 1853 |
}% |
| 1854 |
} |
| 1855 |
% \end{macrocode} |
| 1856 |
% \end{macro} |
| 1857 |
% \begin{macro}{\BitSet@Xor} |
| 1858 |
% \begin{macrocode} |
| 1859 |
\def\BitSet@Xor#1#2!#3#4!#5!{% |
| 1860 |
\ifx\\#2\\% |
| 1861 |
\ifx#1#3% |
| 1862 |
\ifx\\#4\\% |
| 1863 |
\else |
| 1864 |
#50#4% |
| 1865 |
\fi |
| 1866 |
\else |
| 1867 |
#51#4% |
| 1868 |
\fi |
| 1869 |
\else |
| 1870 |
\ifx\\#4\\% |
| 1871 |
#5% |
| 1872 |
\ifx#1#30\else 1\fi |
| 1873 |
#2% |
| 1874 |
\else |
| 1875 |
\ifx#1#3% |
| 1876 |
\BitSet@AfterFiFiFi{% |
| 1877 |
\BitSet@Xor#2!#4!#50!% |
| 1878 |
}% |
| 1879 |
\else |
| 1880 |
#51% |
| 1881 |
\BitSet@AfterFiFiFi{% |
| 1882 |
\BitSet@Xor#2!#4!!% |
| 1883 |
}% |
| 1884 |
\fi |
| 1885 |
\fi |
| 1886 |
\BitSet@Fi |
| 1887 |
} |
| 1888 |
% \end{macrocode} |
| 1889 |
% \end{macro} |
| 1890 |
% |
| 1891 |
% \subsubsection{Shifting}\label{src:shift} |
| 1892 |
% |
| 1893 |
% \subsubsection{\cs{bitsetShiftLeft}} |
| 1894 |
% |
| 1895 |
% \begin{macro}{\bitsetShiftLeft} |
| 1896 |
% \begin{macrocode} |
| 1897 |
\def\bitsetShiftLeft#1#2{% |
| 1898 |
\BitSet@IfUndefined{#1}{% |
| 1899 |
\bitsetReset{#1}% |
| 1900 |
}{% |
| 1901 |
\bitsetIsEmpty{#1}{% |
| 1902 |
}{% |
| 1903 |
\expandafter\expandafter\expandafter\BitSet@ShiftLeft |
| 1904 |
\intcalcNum{#2}!{#1}% |
| 1905 |
}% |
| 1906 |
}% |
| 1907 |
} |
| 1908 |
% \end{macrocode} |
| 1909 |
% \end{macro} |
| 1910 |
% \begin{macro}{\BitSet@ShiftLeft} |
| 1911 |
% \begin{macrocode} |
| 1912 |
\def\BitSet@ShiftLeft#1!#2{% |
| 1913 |
\ifcase\intcalcSgn{#1} % |
| 1914 |
\or |
| 1915 |
\begingroup |
| 1916 |
\uccode`m=`0 % |
| 1917 |
\uppercase\expandafter{\expandafter\endgroup |
| 1918 |
\expandafter\edef\csname BS@#2\expandafter\endcsname |
| 1919 |
\expandafter{% |
| 1920 |
\romannumeral#1000\expandafter\BitSet@Space |
| 1921 |
\csname BS@#2\endcsname |
| 1922 |
}% |
| 1923 |
}% |
| 1924 |
\else |
| 1925 |
\expandafter\BitSet@ShiftRight\BitSet@Gobble#1!{#2}% |
| 1926 |
\fi |
| 1927 |
} |
| 1928 |
% \end{macrocode} |
| 1929 |
% \end{macro} |
| 1930 |
% |
| 1931 |
% \subsubsection{\cs{bitsetShiftRight}} |
| 1932 |
% |
| 1933 |
% \begin{macro}{\bitsetShiftRight} |
| 1934 |
% \begin{macrocode} |
| 1935 |
\def\bitsetShiftRight#1#2{% |
| 1936 |
\BitSet@IfUndefined{#1}{% |
| 1937 |
\bitsetReset{#1}% |
| 1938 |
}{% |
| 1939 |
\bitsetIsEmpty{#1}{% |
| 1940 |
}{% |
| 1941 |
\expandafter\expandafter\expandafter\BitSet@ShiftRight |
| 1942 |
\intcalcNum{#2}!{#1}% |
| 1943 |
}% |
| 1944 |
}% |
| 1945 |
} |
| 1946 |
% \end{macrocode} |
| 1947 |
% \end{macro} |
| 1948 |
% \begin{macro}{\BitSet@ShiftRight} |
| 1949 |
% \begin{macrocode} |
| 1950 |
\def\BitSet@ShiftRight#1!#2{% |
| 1951 |
\ifcase\intcalcSgn{#1} % |
| 1952 |
\or |
| 1953 |
\expandafter\edef\csname BS@#2\endcsname{% |
| 1954 |
\expandafter\expandafter\expandafter\BitSet@Kill |
| 1955 |
\csname BS@#2\expandafter\endcsname\expandafter\BitSet@Empty |
| 1956 |
\expandafter=% |
| 1957 |
\expandafter{\expandafter}\expandafter{\expandafter}% |
| 1958 |
\romannumeral#1000!% |
| 1959 |
}% |
| 1960 |
\else |
| 1961 |
\expandafter\BitSet@ShiftLeft\BitSet@Gobble#1!{#2}% |
| 1962 |
\fi |
| 1963 |
} |
| 1964 |
% \end{macrocode} |
| 1965 |
% \end{macro} |
| 1966 |
% \begin{macro}{\BitSet@Kill} |
| 1967 |
% \begin{macrocode} |
| 1968 |
\def\BitSet@Kill#1#2=#3#4#5{% |
| 1969 |
#3#4% |
| 1970 |
\ifx#5!% |
| 1971 |
\ifx#1\BitSet@Empty |
| 1972 |
0% |
| 1973 |
\else |
| 1974 |
#1#2% |
| 1975 |
\fi |
| 1976 |
\else |
| 1977 |
\ifx#1\BitSet@Empty |
| 1978 |
0% |
| 1979 |
\BitSet@AfterFiFi\BitSet@Cleanup |
| 1980 |
\else |
| 1981 |
\BitSet@Kill#2=% |
| 1982 |
\fi |
| 1983 |
\BitSet@Fi |
| 1984 |
} |
| 1985 |
% \end{macrocode} |
| 1986 |
% \end{macro} |
| 1987 |
% |
| 1988 |
% \subsection{Bit manipulation}\label{src:bitman} |
| 1989 |
% |
| 1990 |
% \begin{macro}{\bitsetClear} |
| 1991 |
% \begin{macrocode} |
| 1992 |
\def\bitsetClear{% |
| 1993 |
\BitSet@CheckIndex\BitSet@Clear |
| 1994 |
} |
| 1995 |
% \end{macrocode} |
| 1996 |
% \end{macro} |
| 1997 |
% \begin{macro}{\bitsetSet} |
| 1998 |
% \begin{macrocode} |
| 1999 |
\def\bitsetSet{% |
| 2000 |
\BitSet@CheckIndex\BitSet@Set |
| 2001 |
} |
| 2002 |
% \end{macrocode} |
| 2003 |
% \end{macro} |
| 2004 |
% \begin{macro}{\bitsetFlip} |
| 2005 |
% \begin{macrocode} |
| 2006 |
\def\bitsetFlip{% |
| 2007 |
\BitSet@CheckIndex\BitSet@Flip |
| 2008 |
} |
| 2009 |
% \end{macrocode} |
| 2010 |
% \end{macro} |
| 2011 |
% \begin{macro}{\bitsetSetValue} |
| 2012 |
% \begin{macrocode} |
| 2013 |
\def\bitsetSetValue#1#2#3{% |
| 2014 |
\expandafter\expandafter\expandafter\BitSet@SetValue |
| 2015 |
\intcalcNum{#3}!{#1}{#2}% |
| 2016 |
} |
| 2017 |
% \end{macrocode} |
| 2018 |
% \end{macro} |
| 2019 |
% \begin{macro}{\BitSet@SetValue} |
| 2020 |
% |#1|: plain value\\ |
| 2021 |
% |#2|: BitSet\\ |
| 2022 |
% |#3|: Index |
| 2023 |
% \begin{macrocode} |
| 2024 |
\def\BitSet@SetValue#1!{% |
| 2025 |
\BitSet@CheckIndex{% |
| 2026 |
\ifcase#1 % |
| 2027 |
\expandafter\BitSet@Clear |
| 2028 |
\or |
| 2029 |
\expandafter\BitSet@Set |
| 2030 |
\else |
| 2031 |
\BitSet@ErrorInvalidBitValue{#1}% |
| 2032 |
\expandafter\expandafter\expandafter\BitSet@Gobble |
| 2033 |
\expandafter\BitSet@Gobble |
| 2034 |
\fi |
| 2035 |
}% |
| 2036 |
} |
| 2037 |
% \end{macrocode} |
| 2038 |
% \end{macro} |
| 2039 |
% \begin{macro}{\BitSet@ErrorInvalidBitValue} |
| 2040 |
% |#1|: Wrong bit value |
| 2041 |
% \begin{macrocode} |
| 2042 |
\def\BitSet@ErrorInvalidBitValue#1{% |
| 2043 |
\@PackageError{bitset}{% |
| 2044 |
Invalid bit value (#1) not in range 0..1% |
| 2045 |
}\@ehc |
| 2046 |
} |
| 2047 |
% \end{macrocode} |
| 2048 |
% \end{macro} |
| 2049 |
% |
| 2050 |
% \subsubsection{Clear operation} |
| 2051 |
% |
| 2052 |
% \begin{macro}{\BitSet@Clear} |
| 2053 |
% |#1|: BitSet\\ |
| 2054 |
% |#2|: plain and checked index |
| 2055 |
% \begin{macrocode} |
| 2056 |
\def\BitSet@Clear#1#2{% |
| 2057 |
\edef\BitSet@Temp{% |
| 2058 |
\expandafter\expandafter\expandafter\BitSet@@Clear |
| 2059 |
\csname BS@#1\expandafter\endcsname |
| 2060 |
\expandafter\BitSet@Empty\expandafter=\expandafter!% |
| 2061 |
\romannumeral#2000!% |
| 2062 |
}% |
| 2063 |
\expandafter\let\csname BS@#1\expandafter\endcsname |
| 2064 |
\ifx\BitSet@Temp\BitSet@Empty |
| 2065 |
\BitSet@Zero |
| 2066 |
\else |
| 2067 |
\BitSet@Temp |
| 2068 |
\fi |
| 2069 |
} |
| 2070 |
% \end{macrocode} |
| 2071 |
% \end{macro} |
| 2072 |
% \begin{macro}{\BitSet@@Clear} |
| 2073 |
% \begin{macrocode} |
| 2074 |
\def\BitSet@@Clear#1#2=#3!#4{% |
| 2075 |
\ifx#4!% |
| 2076 |
\ifx#1\BitSet@Empty |
| 2077 |
\else |
| 2078 |
\ifx\BitSet@Empty#2% |
| 2079 |
\else |
| 2080 |
#30#2% |
| 2081 |
\fi |
| 2082 |
\fi |
| 2083 |
\else |
| 2084 |
\ifx#1\BitSet@Empty |
| 2085 |
\BitSet@AfterFiFi\BitSet@Cleanup |
| 2086 |
\else |
| 2087 |
\ifx#10% |
| 2088 |
\BitSet@AfterFiFiFi{% |
| 2089 |
\BitSet@@Clear#2=#30!% |
| 2090 |
}% |
| 2091 |
\else |
| 2092 |
#31% |
| 2093 |
\BitSet@AfterFiFiFi{% |
| 2094 |
\BitSet@@Clear#2=!% |
| 2095 |
}% |
| 2096 |
\fi |
| 2097 |
\fi |
| 2098 |
\BitSet@Fi |
| 2099 |
} |
| 2100 |
% \end{macrocode} |
| 2101 |
% \end{macro} |
| 2102 |
% |
| 2103 |
% \subsubsection{Set operation} |
| 2104 |
% |
| 2105 |
% \begin{macro}{\BitSet@Set} |
| 2106 |
% |#1|: BitSet\\ |
| 2107 |
% |#2|: plain and checked Index |
| 2108 |
% \begin{macrocode} |
| 2109 |
\def\BitSet@Set#1#2{% |
| 2110 |
\expandafter\edef\csname BS@#1\endcsname{% |
| 2111 |
\expandafter\expandafter\expandafter\BitSet@@Set |
| 2112 |
\csname BS@#1\expandafter\endcsname |
| 2113 |
\expandafter\BitSet@Empty\expandafter=% |
| 2114 |
\expandafter{\expandafter}\expandafter{\expandafter}% |
| 2115 |
\romannumeral#2000!% |
| 2116 |
}% |
| 2117 |
} |
| 2118 |
% \end{macrocode} |
| 2119 |
% \end{macro} |
| 2120 |
% \begin{macro}{\BitSet@@Set} |
| 2121 |
% \begin{macrocode} |
| 2122 |
\def\BitSet@@Set#1#2=#3#4#5{% |
| 2123 |
#3#4% |
| 2124 |
\ifx#5!% |
| 2125 |
1#2% |
| 2126 |
\else |
| 2127 |
\ifx#1\BitSet@Empty |
| 2128 |
0% |
| 2129 |
\BitSet@AfterFiFi\BitSet@@@Set |
| 2130 |
\else |
| 2131 |
#1% |
| 2132 |
\BitSet@@Set#2=% |
| 2133 |
\fi |
| 2134 |
\BitSet@Fi |
| 2135 |
} |
| 2136 |
% \end{macrocode} |
| 2137 |
% \end{macro} |
| 2138 |
% \begin{macro}{\BitSet@@@Set} |
| 2139 |
% \begin{macrocode} |
| 2140 |
\def\BitSet@@@Set#1{% |
| 2141 |
\ifx#1!% |
| 2142 |
1% |
| 2143 |
\else |
| 2144 |
0% |
| 2145 |
\expandafter\BitSet@@@Set |
| 2146 |
\fi |
| 2147 |
} |
| 2148 |
% \end{macrocode} |
| 2149 |
% \end{macro} |
| 2150 |
% |
| 2151 |
% \subsubsection{Flip operation} |
| 2152 |
% |
| 2153 |
% \begin{macro}{\BitSet@Flip} |
| 2154 |
% |#1|: BitSet\\ |
| 2155 |
% |#2|: plain and checked Index |
| 2156 |
% \begin{macrocode} |
| 2157 |
\def\BitSet@Flip#1#2{% |
| 2158 |
\edef\BitSet@Temp{% |
| 2159 |
\expandafter\expandafter\expandafter\BitSet@@Flip |
| 2160 |
\csname BS@#1\expandafter\endcsname |
| 2161 |
\expandafter\BitSet@Empty\expandafter=\expandafter!% |
| 2162 |
\romannumeral#2000!% |
| 2163 |
}% |
| 2164 |
\expandafter\let\csname BS@#1\expandafter\endcsname |
| 2165 |
\ifx\BitSet@Temp\BitSet@Empty |
| 2166 |
\BitSet@Zero |
| 2167 |
\else |
| 2168 |
\BitSet@Temp |
| 2169 |
\fi |
| 2170 |
} |
| 2171 |
% \end{macrocode} |
| 2172 |
% \end{macro} |
| 2173 |
% \begin{macro}{\BitSet@@Flip} |
| 2174 |
% \begin{macrocode} |
| 2175 |
\def\BitSet@@Flip#1#2=#3!#4{% |
| 2176 |
\ifx#4!% |
| 2177 |
\ifx#11% |
| 2178 |
\ifx\BitSet@Empty#2% |
| 2179 |
\else |
| 2180 |
#30#2% |
| 2181 |
\fi |
| 2182 |
\else |
| 2183 |
#31#2% |
| 2184 |
\fi |
| 2185 |
\else |
| 2186 |
\ifx#1\BitSet@Empty |
| 2187 |
#30% |
| 2188 |
\BitSet@AfterFiFi\BitSet@@@Set |
| 2189 |
\else |
| 2190 |
\ifx#10% |
| 2191 |
\BitSet@AfterFiFiFi{% |
| 2192 |
\BitSet@@Flip#2=#30!% |
| 2193 |
}% |
| 2194 |
\else |
| 2195 |
#31% |
| 2196 |
\BitSet@AfterFiFiFi{% |
| 2197 |
\BitSet@@Flip#2=!% |
| 2198 |
}% |
| 2199 |
\fi |
| 2200 |
\fi |
| 2201 |
\BitSet@Fi |
| 2202 |
} |
| 2203 |
% \end{macrocode} |
| 2204 |
% \end{macro} |
| 2205 |
% |
| 2206 |
% \subsubsection{Range operators} |
| 2207 |
% |
| 2208 |
% \begin{macro}{\bitsetClearRange} |
| 2209 |
% \begin{macrocode} |
| 2210 |
\def\bitsetClearRange{% |
| 2211 |
\BitSet@Range\BitSet@Clear |
| 2212 |
} |
| 2213 |
% \end{macrocode} |
| 2214 |
% \end{macro} |
| 2215 |
% \begin{macro}{\bitsetSetRange} |
| 2216 |
% \begin{macrocode} |
| 2217 |
\def\bitsetSetRange{% |
| 2218 |
\BitSet@Range\BitSet@Set |
| 2219 |
} |
| 2220 |
% \end{macrocode} |
| 2221 |
% \end{macro} |
| 2222 |
% \begin{macro}{\bitsetFlipRange} |
| 2223 |
% \begin{macrocode} |
| 2224 |
\def\bitsetFlipRange{% |
| 2225 |
\BitSet@Range\BitSet@Flip |
| 2226 |
} |
| 2227 |
% \end{macrocode} |
| 2228 |
% \end{macro} |
| 2229 |
% \begin{macro}{\bitsetSetValueRange} |
| 2230 |
% \begin{macrocode} |
| 2231 |
\def\bitsetSetValueRange#1#2#3#4{% |
| 2232 |
\expandafter\expandafter\expandafter\BitSet@SetValueRange |
| 2233 |
\intcalcNum{#4}!{#1}{#2}{#3}% |
| 2234 |
} |
| 2235 |
% \end{macrocode} |
| 2236 |
% \end{macro} |
| 2237 |
% \begin{macro}{\BitSet@SetValueRange} |
| 2238 |
% \begin{macrocode} |
| 2239 |
\def\BitSet@SetValueRange#1!#2#3#4{% |
| 2240 |
\ifcase#1 % |
| 2241 |
\BitSet@Range\BitSet@Clear{#2}{#3}{#4}% |
| 2242 |
\or |
| 2243 |
\BitSet@Range\BitSet@Set{#2}{#3}{#4}% |
| 2244 |
\else |
| 2245 |
\BitSet@ErrorInvalidBitValue{#1}% |
| 2246 |
\fi |
| 2247 |
} |
| 2248 |
% \end{macrocode} |
| 2249 |
% \end{macro} |
| 2250 |
% |
| 2251 |
% \begin{macro}{\BitSet@Range} |
| 2252 |
% |#1|: clear/set/flip macro\\ |
| 2253 |
% |#2|: BitSet\\ |
| 2254 |
% |#3|: Index from\\ |
| 2255 |
% |#4|: Index to |
| 2256 |
% \begin{macrocode} |
| 2257 |
\def\BitSet@Range#1#2#3#4{% |
| 2258 |
\edef\BitSet@Temp{% |
| 2259 |
\noexpand\BitSet@@Range\noexpand#1{#2}% |
| 2260 |
\intcalcNum{#3}!\intcalcNum{#4}!% |
| 2261 |
}% |
| 2262 |
\BitSet@Temp |
| 2263 |
} |
| 2264 |
% \end{macrocode} |
| 2265 |
% \end{macro} |
| 2266 |
% \begin{macro}{\BitSet@@Range} |
| 2267 |
% |#1|: clear/set/flip macro\\ |
| 2268 |
% |#2|: BitSet\\ |
| 2269 |
% |#3|: Index from\\ |
| 2270 |
% |#4|: Index to |
| 2271 |
% \begin{macrocode} |
| 2272 |
\def\BitSet@@Range#1#2#3!#4!{% |
| 2273 |
\ifnum#3<0 % |
| 2274 |
\BitSet@NegativeIndex#1{#2}#3!#4!0!#4!% |
| 2275 |
\else |
| 2276 |
\ifnum#4<0 % |
| 2277 |
\BitSet@NegativeIndex#1{#2}#3!#4!#3!0!% |
| 2278 |
\else |
| 2279 |
\ifcase\intcalcCmp{#3}{#4} % |
| 2280 |
\or |
| 2281 |
\@PackageError{bitset}{% |
| 2282 |
Wrong index numbers in range [#3..#4]\MessageBreak% hash-ok |
| 2283 |
for clear/set/flip on bit set `#2'.\MessageBreak |
| 2284 |
The lower index exceeds the upper index.\MessageBreak |
| 2285 |
Canceling the operation as error recovery% |
| 2286 |
}\@ehc |
| 2287 |
\else |
| 2288 |
\BitSet@@@Range#3!#4!#1{#2}% |
| 2289 |
\fi |
| 2290 |
\fi |
| 2291 |
\fi |
| 2292 |
} |
| 2293 |
% \end{macrocode} |
| 2294 |
% \end{macro} |
| 2295 |
% \begin{macro}{\BitSet@NegativeIndex} |
| 2296 |
% \begin{macrocode} |
| 2297 |
\def\BitSet@NegativeIndex#1#2#3!#4!#5!#6!{% |
| 2298 |
\@PackageError{bitset}{% |
| 2299 |
Negative index in range [#3..#4]\MessageBreak % hash-ok |
| 2300 |
for \string\bitset |
| 2301 |
\ifx#1\BitSet@Clear |
| 2302 |
Clear% |
| 2303 |
\else |
| 2304 |
\ifx#1\BitSet@Set |
| 2305 |
Set% |
| 2306 |
\else |
| 2307 |
Flip% |
| 2308 |
\fi |
| 2309 |
\fi |
| 2310 |
Range on bit set `#2'.\MessageBreak |
| 2311 |
Using [#5..#6] as error recovery% hash-ok |
| 2312 |
}\@ehc |
| 2313 |
\BitSet@@Range#1{#2}#5!#6!% |
| 2314 |
} |
| 2315 |
% \end{macrocode} |
| 2316 |
% \end{macro} |
| 2317 |
% \begin{macro}{\BitSet@@Range} |
| 2318 |
% \begin{macrocode} |
| 2319 |
\def\BitSet@@@Range#1!#2!#3#4{% |
| 2320 |
\ifnum#1<#2 % |
| 2321 |
#3{#4}{#1}% |
| 2322 |
\BitSet@AfterFi{% |
| 2323 |
\expandafter\expandafter\expandafter\BitSet@@@Range |
| 2324 |
\IntCalcInc#1!!#2!#3{#4}% |
| 2325 |
}% |
| 2326 |
\BitSet@Fi |
| 2327 |
} |
| 2328 |
% \end{macrocode} |
| 2329 |
% \end{macro} |
| 2330 |
% |
| 2331 |
% \subsection{Bit retrieval}\label{src:bitret} |
| 2332 |
% |
| 2333 |
% \subsubsection{\cs{bitsetGet}} |
| 2334 |
% |
| 2335 |
% \begin{macro}{\bitsetGet} |
| 2336 |
% \begin{macrocode} |
| 2337 |
\def\bitsetGet#1#2{% |
| 2338 |
\number |
| 2339 |
\expandafter\expandafter\expandafter\BitSet@Get |
| 2340 |
\intcalcNum{#2}!{#1}% |
| 2341 |
} |
| 2342 |
% \end{macrocode} |
| 2343 |
% \end{macro} |
| 2344 |
% \begin{macro}{\BitSet@Get} |
| 2345 |
% |#1|: plain index\\ |
| 2346 |
% |#2|: BitSet |
| 2347 |
% \begin{macrocode} |
| 2348 |
\def\BitSet@Get#1!#2{% |
| 2349 |
\ifnum#1<0 % |
| 2350 |
\BitSet@AfterFi{% |
| 2351 |
0 \BitSetError:NegativeIndex% |
| 2352 |
}% |
| 2353 |
\else |
| 2354 |
\BitSet@IfUndefined{#2}{0}{% |
| 2355 |
\expandafter\expandafter\expandafter\BitSet@@Get |
| 2356 |
\csname BS@#2\expandafter\endcsname |
| 2357 |
\expandafter!\expandafter=% |
| 2358 |
\expandafter{\expandafter}\expandafter{\expandafter}% |
| 2359 |
\romannumeral\intcalcNum{#1}000!% |
| 2360 |
}% |
| 2361 |
\expandafter\BitSet@Space |
| 2362 |
\BitSet@Fi |
| 2363 |
} |
| 2364 |
% \end{macrocode} |
| 2365 |
% \end{macro} |
| 2366 |
% \begin{macro}{\BitSet@@Get} |
| 2367 |
% \begin{macrocode} |
| 2368 |
\def\BitSet@@Get#1#2=#3#4#5{% |
| 2369 |
#3#4% |
| 2370 |
\ifx#5!% |
| 2371 |
\ifx#1!% |
| 2372 |
0% |
| 2373 |
\else |
| 2374 |
#1% |
| 2375 |
\fi |
| 2376 |
\else |
| 2377 |
\ifx#1!% |
| 2378 |
0% |
| 2379 |
\BitSet@AfterFiFi\BitSet@Cleanup |
| 2380 |
\else |
| 2381 |
\BitSet@@Get#2=% |
| 2382 |
\fi |
| 2383 |
\BitSet@Fi |
| 2384 |
} |
| 2385 |
% \end{macrocode} |
| 2386 |
% \end{macro} |
| 2387 |
% |
| 2388 |
% \subsubsection{\cs{bitsetNextClearBit}, \cs{bitsetNextSetBit}} |
| 2389 |
% |
| 2390 |
% \begin{macro}{\bitsetNextClearBit} |
| 2391 |
% \begin{macrocode} |
| 2392 |
\def\bitsetNextClearBit#1#2{% |
| 2393 |
\number |
| 2394 |
\expandafter\expandafter\expandafter\BitSet@NextClearBit |
| 2395 |
\intcalcNum{#2}!{#1} % |
| 2396 |
} |
| 2397 |
% \end{macrocode} |
| 2398 |
% \end{macro} |
| 2399 |
% \begin{macro}{\BitSet@NextClearBit} |
| 2400 |
% |#1|: Index\\ |
| 2401 |
% |#2|: BitSet |
| 2402 |
% \begin{macrocode} |
| 2403 |
\def\BitSet@NextClearBit#1!#2{% |
| 2404 |
\ifnum#1<0 % |
| 2405 |
\BitSet@NextClearBit0!{#2}% |
| 2406 |
\BitSet@AfterFi{% |
| 2407 |
\expandafter\BitSet@Space |
| 2408 |
\expandafter\BitSetError:NegativeIndex\romannumeral0% |
| 2409 |
}% |
| 2410 |
\else |
| 2411 |
\bitsetIsEmpty{#2}{#1}{% |
| 2412 |
\expandafter\BitSet@Skip |
| 2413 |
\number#1\expandafter\expandafter\expandafter!% |
| 2414 |
\csname BS@#2\endcsname!!!!!!!!!=% |
| 2415 |
{\BitSet@@NextClearBit#1!}% |
| 2416 |
}% |
| 2417 |
\BitSet@Fi |
| 2418 |
} |
| 2419 |
% \end{macrocode} |
| 2420 |
% \end{macro} |
| 2421 |
% \begin{macro}{\BitSet@@NextClearBit} |
| 2422 |
% |#1|: index for next bit in |#2|\\ |
| 2423 |
% |#2|: next bit |
| 2424 |
% \begin{macrocode} |
| 2425 |
\def\BitSet@@NextClearBit#1!#2{% |
| 2426 |
\ifx#2!% |
| 2427 |
#1% |
| 2428 |
\else |
| 2429 |
\ifx#20% |
| 2430 |
#1% |
| 2431 |
\BitSet@AfterFiFi\BitSet@Cleanup |
| 2432 |
\else |
| 2433 |
\BitSet@AfterFiFi{% |
| 2434 |
\expandafter\expandafter\expandafter\BitSet@@NextClearBit |
| 2435 |
\IntCalcInc#1!!% |
| 2436 |
}% |
| 2437 |
\fi |
| 2438 |
\BitSet@Fi |
| 2439 |
} |
| 2440 |
% \end{macrocode} |
| 2441 |
% \end{macro} |
| 2442 |
% |
| 2443 |
% \begin{macro}{\bitsetNextSetBit} |
| 2444 |
% \begin{macrocode} |
| 2445 |
\def\bitsetNextSetBit#1#2{% |
| 2446 |
\number |
| 2447 |
\expandafter\expandafter\expandafter\BitSet@NextSetBit |
| 2448 |
\intcalcNum{#2}!{#1} % |
| 2449 |
} |
| 2450 |
% \end{macrocode} |
| 2451 |
% \end{macro} |
| 2452 |
% \begin{macro}{\BitSet@NextSetBit} |
| 2453 |
% |#1|: Index\\ |
| 2454 |
% |#2|: BitSet |
| 2455 |
% \begin{macrocode} |
| 2456 |
\def\BitSet@NextSetBit#1!#2{% |
| 2457 |
\ifnum#1<0 % |
| 2458 |
\BitSet@NextSetBit0!{#2}% |
| 2459 |
\BitSet@AfterFi{% |
| 2460 |
\expandafter\BitSet@Space |
| 2461 |
\expandafter\BitSetError:NegativeIndex\romannumeral0% |
| 2462 |
}% |
| 2463 |
\else |
| 2464 |
\bitsetIsEmpty{#2}{-1}{% |
| 2465 |
\expandafter\BitSet@Skip |
| 2466 |
\number#1\expandafter\expandafter\expandafter!% |
| 2467 |
\csname BS@#2\endcsname!!!!!!!!!=% |
| 2468 |
{\BitSet@@NextSetBit#1!}% |
| 2469 |
}% |
| 2470 |
\BitSet@Fi |
| 2471 |
} |
| 2472 |
% \end{macrocode} |
| 2473 |
% \end{macro} |
| 2474 |
% \begin{macro}{\BitSet@@NextSetBit} |
| 2475 |
% |#1|: index for next bit in |#2|\\ |
| 2476 |
% |#2|: next bit |
| 2477 |
% \begin{macrocode} |
| 2478 |
\def\BitSet@@NextSetBit#1!#2{% |
| 2479 |
\ifx#2!% |
| 2480 |
-1% |
| 2481 |
\else |
| 2482 |
\ifx#21% |
| 2483 |
#1% |
| 2484 |
\BitSet@AfterFiFi\BitSet@Cleanup |
| 2485 |
\else |
| 2486 |
\BitSet@AfterFiFi{% |
| 2487 |
\expandafter\expandafter\expandafter\BitSet@@NextSetBit |
| 2488 |
\IntCalcInc#1!!% |
| 2489 |
}% |
| 2490 |
\fi |
| 2491 |
\BitSet@Fi |
| 2492 |
} |
| 2493 |
% \end{macrocode} |
| 2494 |
% \end{macro} |
| 2495 |
% \begin{macro}{\BitSet@Cleanup} |
| 2496 |
% \begin{macrocode} |
| 2497 |
\def\BitSet@Cleanup#1!{} |
| 2498 |
% \end{macrocode} |
| 2499 |
% \end{macro} |
| 2500 |
% |
| 2501 |
% \begin{macro}{\BitSet@Skip} |
| 2502 |
% |#1|: number of bits to skip\\ |
| 2503 |
% |#2|: bits\\ |
| 2504 |
% |#3|: continuation code |
| 2505 |
% \begin{macrocode} |
| 2506 |
\def\BitSet@Skip#1!#2{% |
| 2507 |
\ifx#2!% |
| 2508 |
\BitSet@AfterFi{% |
| 2509 |
\BitSet@SkipContinue% |
| 2510 |
}% |
| 2511 |
\else |
| 2512 |
\ifcase#1 % |
| 2513 |
\BitSet@AfterFiFi{% |
| 2514 |
\BitSet@SkipContinue#2% |
| 2515 |
}% |
| 2516 |
\or |
| 2517 |
\BitSet@AfterFiFi\BitSet@SkipContinue |
| 2518 |
\or |
| 2519 |
\BitSet@AfterFiFi{% |
| 2520 |
\expandafter\BitSet@SkipContinue\BitSet@Gobble |
| 2521 |
}% |
| 2522 |
\else |
| 2523 |
\ifnum#1>8 % |
| 2524 |
\BitSet@AfterFiFiFi{% |
| 2525 |
\expandafter\BitSet@Skip |
| 2526 |
\number\IntCalcSub#1!8!\expandafter!% |
| 2527 |
\BitSet@GobbleSeven |
| 2528 |
}% |
| 2529 |
\else |
| 2530 |
\BitSet@AfterFiFiFi{% |
| 2531 |
\expandafter\expandafter\expandafter\BitSet@Skip |
| 2532 |
\IntCalcDec#1!!% |
| 2533 |
}% |
| 2534 |
\fi |
| 2535 |
\fi |
| 2536 |
\BitSet@Fi |
| 2537 |
} |
| 2538 |
% \end{macrocode} |
| 2539 |
% \end{macro} |
| 2540 |
% \begin{macro}{\BitSet@SkipContinue} |
| 2541 |
% |#1|: remaining bits\\ |
| 2542 |
% |#2|: continuation code |
| 2543 |
% \begin{macrocode} |
| 2544 |
\def\BitSet@SkipContinue#1!#2=#3{% |
| 2545 |
#3#1!% |
| 2546 |
} |
| 2547 |
% \end{macrocode} |
| 2548 |
% \end{macro} |
| 2549 |
% \begin{macro}{\BitSet@GobbleSeven} |
| 2550 |
% \begin{macrocode} |
| 2551 |
\def\BitSet@GobbleSeven#1#2#3#4#5#6#7{} |
| 2552 |
% \end{macrocode} |
| 2553 |
% \end{macro} |
| 2554 |
% |
| 2555 |
% \subsubsection{\cs{bitsetGetSetBitList}} |
| 2556 |
% |
| 2557 |
% \begin{macro}{\bitsetGetSetBitList} |
| 2558 |
% It's just a wrapper for \cs{bitsetNextSetBit}. |
| 2559 |
% \begin{macrocode} |
| 2560 |
\def\bitsetGetSetBitList#1{% |
| 2561 |
\romannumeral0% |
| 2562 |
\bitsetIsEmpty{#1}{ }{% |
| 2563 |
\expandafter\BitSet@GetSetBitList |
| 2564 |
\number\BitSet@NextSetBit0!{#1}!{#1}{}!% |
| 2565 |
}% |
| 2566 |
} |
| 2567 |
% \end{macrocode} |
| 2568 |
% \end{macro} |
| 2569 |
% \begin{macro}{\BitSet@GetSetBitList} |
| 2570 |
% |#1|: found index\\ |
| 2571 |
% |#2|: BitSet\\ |
| 2572 |
% |#3|: comma |
| 2573 |
% |#4|: result |
| 2574 |
% \begin{macrocode} |
| 2575 |
\def\BitSet@GetSetBitList#1!#2#3#4!{% |
| 2576 |
\ifnum#1<0 % |
| 2577 |
\BitSet@AfterFi{ #4}% |
| 2578 |
\else |
| 2579 |
\BitSet@AfterFi{% |
| 2580 |
\expandafter\BitSet@GetSetBitList\number |
| 2581 |
\expandafter\expandafter\expandafter\BitSet@NextSetBit |
| 2582 |
\IntCalcInc#1!!{#2}!{#2},#4#3#1!% |
| 2583 |
}% |
| 2584 |
\BitSet@Fi |
| 2585 |
} |
| 2586 |
% \end{macrocode} |
| 2587 |
% \end{macro} |
| 2588 |
% |
| 2589 |
% \subsection{Bit set properties}\label{src:prop} |
| 2590 |
% |
| 2591 |
% \begin{macro}{\bitsetSize} |
| 2592 |
% \begin{macrocode} |
| 2593 |
\def\bitsetSize#1{% |
| 2594 |
\number |
| 2595 |
\BitSet@IfUndefined{#1}{0 }{% |
| 2596 |
\expandafter\expandafter\expandafter\BitSet@Size |
| 2597 |
\expandafter\expandafter\expandafter1% |
| 2598 |
\expandafter\expandafter\expandafter!% |
| 2599 |
\csname BS@#1\endcsname!0!% |
| 2600 |
}% |
| 2601 |
} |
| 2602 |
% \end{macrocode} |
| 2603 |
% \end{macro} |
| 2604 |
% \begin{macro}{\BitSet@Size} |
| 2605 |
% |#1|: counter\\ |
| 2606 |
% |#2#3|: bits\\ |
| 2607 |
% |#4|: result |
| 2608 |
% \begin{macrocode} |
| 2609 |
\def\BitSet@Size#1!#2#3!#4!{% |
| 2610 |
\ifx#21% |
| 2611 |
\ifx\\#3\\% |
| 2612 |
\BitSet@AfterFiFi{#1 }% |
| 2613 |
\else |
| 2614 |
\BitSet@AfterFiFi{% |
| 2615 |
\expandafter\expandafter\expandafter\BitSet@Size |
| 2616 |
\IntCalcInc#1!!#3!#1!% |
| 2617 |
}% |
| 2618 |
\fi |
| 2619 |
\else |
| 2620 |
\ifx\\#3\\% |
| 2621 |
\BitSet@AfterFiFi{#4 }% |
| 2622 |
\else |
| 2623 |
\BitSet@AfterFiFi{% |
| 2624 |
\expandafter\expandafter\expandafter\BitSet@Size |
| 2625 |
\IntCalcInc#1!!#3!#4!% |
| 2626 |
}% |
| 2627 |
\fi |
| 2628 |
\fi |
| 2629 |
\BitSet@Fi |
| 2630 |
} |
| 2631 |
% \end{macrocode} |
| 2632 |
% \end{macro} |
| 2633 |
% |
| 2634 |
% \begin{macro}{\bitsetCardinality} |
| 2635 |
% \begin{macrocode} |
| 2636 |
\def\bitsetCardinality#1{% |
| 2637 |
\number |
| 2638 |
\BitSet@IfUndefined{#1}{0 }{% |
| 2639 |
\expandafter\expandafter\expandafter\BitSet@Cardinality |
| 2640 |
\expandafter\expandafter\expandafter0% |
| 2641 |
\expandafter\expandafter\expandafter!% |
| 2642 |
\csname BS@#1\endcsname!% |
| 2643 |
}% |
| 2644 |
} |
| 2645 |
% \end{macrocode} |
| 2646 |
% \end{macro} |
| 2647 |
% \begin{macro}{\BitSet@Cardinality} |
| 2648 |
% |#1|: result\\ |
| 2649 |
% |#2#3|: bits |
| 2650 |
% \begin{macrocode} |
| 2651 |
\def\BitSet@Cardinality#1!#2#3!{% |
| 2652 |
\ifx#21% |
| 2653 |
\ifx\\#3\\% |
| 2654 |
\BitSet@AfterFiFi{\IntCalcInc#1! }% |
| 2655 |
\else |
| 2656 |
\BitSet@AfterFiFi{% |
| 2657 |
\expandafter\expandafter\expandafter\BitSet@Cardinality |
| 2658 |
\IntCalcInc#1!!#3!% |
| 2659 |
}% |
| 2660 |
\fi |
| 2661 |
\else |
| 2662 |
\ifx\\#3\\% |
| 2663 |
\BitSet@AfterFiFi{#1 }% |
| 2664 |
\else |
| 2665 |
\BitSet@AfterFiFi{% |
| 2666 |
\BitSet@Cardinality#1!#3!% |
| 2667 |
}% |
| 2668 |
\fi |
| 2669 |
\fi |
| 2670 |
\BitSet@Fi |
| 2671 |
} |
| 2672 |
% \end{macrocode} |
| 2673 |
% \end{macro} |
| 2674 |
% |
| 2675 |
% \subsection{Queries}\label{src:query} |
| 2676 |
% |
| 2677 |
% \begin{macro}{\bitsetIsDefined} |
| 2678 |
% \begin{macrocode} |
| 2679 |
\def\bitsetIsDefined#1{% |
| 2680 |
\BitSet@IfUndefined{#1}% |
| 2681 |
\BitSet@SecondOfTwo |
| 2682 |
\BitSet@FirstOfTwo |
| 2683 |
} |
| 2684 |
% \end{macrocode} |
| 2685 |
% \end{macro} |
| 2686 |
% \begin{macro}{\bitsetIsEmpty} |
| 2687 |
% \begin{macrocode} |
| 2688 |
\def\bitsetIsEmpty#1{% |
| 2689 |
\BitSet@IfUndefined{#1}\BitSet@FirstOfTwo{% |
| 2690 |
\expandafter\ifx\csname BS@#1\endcsname\BitSet@Zero |
| 2691 |
\expandafter\BitSet@FirstOfTwo |
| 2692 |
\else |
| 2693 |
\expandafter\BitSet@SecondOfTwo |
| 2694 |
\fi |
| 2695 |
}% |
| 2696 |
} |
| 2697 |
% \end{macrocode} |
| 2698 |
% \end{macro} |
| 2699 |
% \begin{macro}{\BitSet@Zero} |
| 2700 |
% \begin{macrocode} |
| 2701 |
\def\BitSet@Zero{0} |
| 2702 |
% \end{macrocode} |
| 2703 |
% \end{macro} |
| 2704 |
% |
| 2705 |
% \begin{macro}{\bitsetQuery} |
| 2706 |
% \begin{macrocode} |
| 2707 |
\def\bitsetQuery#1#2{% |
| 2708 |
\ifnum\bitsetGet{#1}{#2}=1 % |
| 2709 |
\expandafter\BitSet@FirstOfTwo |
| 2710 |
\else |
| 2711 |
\expandafter\BitSet@SecondOfTwo |
| 2712 |
\fi |
| 2713 |
} |
| 2714 |
% \end{macrocode} |
| 2715 |
% \end{macro} |
| 2716 |
% |
| 2717 |
% \begin{macro}{\bitsetEquals} |
| 2718 |
% \begin{macrocode} |
| 2719 |
\def\bitsetEquals#1#2{% |
| 2720 |
\BitSet@IfUndefined{#1}{% |
| 2721 |
\BitSet@IfUndefined{#2}\BitSet@FirstOfTwo\BitSet@SecondOfTwo |
| 2722 |
}{% |
| 2723 |
\BitSet@IfUndefined{#2}\BitSet@SecondOfTwo{% |
| 2724 |
\expandafter\ifx\csname BS@#1\expandafter\endcsname |
| 2725 |
\csname BS@#2\endcsname |
| 2726 |
\expandafter\BitSet@FirstOfTwo |
| 2727 |
\else |
| 2728 |
\expandafter\BitSet@SecondOfTwo |
| 2729 |
\fi |
| 2730 |
}% |
| 2731 |
}% |
| 2732 |
} |
| 2733 |
% \end{macrocode} |
| 2734 |
% \end{macro} |
| 2735 |
% |
| 2736 |
% \begin{macro}{\bitsetIntersects} |
| 2737 |
% \begin{macrocode} |
| 2738 |
\def\bitsetIntersects#1#2{% |
| 2739 |
\bitsetIsEmpty{#1}\BitSet@SecondOfTwo{% |
| 2740 |
\bitsetIsEmpty{#2}\BitSet@SecondOfTwo{% |
| 2741 |
\expandafter\expandafter\expandafter\BitSet@Intersects |
| 2742 |
\csname BS@#1\expandafter\expandafter\expandafter\endcsname |
| 2743 |
\expandafter\expandafter\expandafter!% |
| 2744 |
\csname BS@#2\endcsname!% |
| 2745 |
}% |
| 2746 |
}% |
| 2747 |
} |
| 2748 |
% \end{macrocode} |
| 2749 |
% \end{macro} |
| 2750 |
% \begin{macro}{\BitSet@Intersects} |
| 2751 |
% \begin{macrocode} |
| 2752 |
\def\BitSet@Intersects#1#2!#3#4!{% |
| 2753 |
\ifnum#1#3=11 % |
| 2754 |
\BitSet@AfterFi\BitSet@FirstOfTwo |
| 2755 |
\else |
| 2756 |
\ifx\\#2\\% |
| 2757 |
\BitSet@AfterFiFi\BitSet@SecondOfTwo |
| 2758 |
\else |
| 2759 |
\ifx\\#4\\% |
| 2760 |
\BitSet@AfterFiFiFi\BitSet@SecondOfTwo |
| 2761 |
\else |
| 2762 |
\BitSet@AfterFiFiFi{% |
| 2763 |
\BitSet@Intersects#2!#4!% |
| 2764 |
}% |
| 2765 |
\fi |
| 2766 |
\fi |
| 2767 |
\BitSet@Fi |
| 2768 |
} |
| 2769 |
% \end{macrocode} |
| 2770 |
% \end{macro} |
| 2771 |
% |
| 2772 |
% \begin{macrocode} |
| 2773 |
\BitSet@AtEnd% |
| 2774 |
%</package> |
| 2775 |
% \end{macrocode} |
| 2776 |
%% \section{Installation} |
| 2777 |
% |
| 2778 |
% \subsection{Download} |
| 2779 |
% |
| 2780 |
% \paragraph{Package.} This package is available on |
| 2781 |
% CTAN\footnote{\CTANpkg{bitset}}: |
| 2782 |
% \begin{description} |
| 2783 |
% \item[\CTAN{macros/latex/contrib/bitset/bitset.dtx}] The source file. |
| 2784 |
% \item[\CTAN{macros/latex/contrib/bitset/bitset.pdf}] Documentation. |
| 2785 |
% \end{description} |
| 2786 |
% |
| 2787 |
% |
| 2788 |
% \paragraph{Bundle.} All the packages of the bundle `bitset' |
| 2789 |
% are also available in a TDS compliant ZIP archive. There |
| 2790 |
% the packages are already unpacked and the documentation files |
| 2791 |
% are generated. The files and directories obey the TDS standard. |
| 2792 |
% \begin{description} |
| 2793 |
% \item[\CTANinstall{install/macros/latex/contrib/bitset.tds.zip}] |
| 2794 |
% \end{description} |
| 2795 |
% \emph{TDS} refers to the standard ``A Directory Structure |
| 2796 |
% for \TeX\ Files'' (\CTANpkg{tds}). Directories |
| 2797 |
% with \xfile{texmf} in their name are usually organized this way. |
| 2798 |
% |
| 2799 |
% \subsection{Bundle installation} |
| 2800 |
% |
| 2801 |
% \paragraph{Unpacking.} Unpack the \xfile{bitset.tds.zip} in the |
| 2802 |
% TDS tree (also known as \xfile{texmf} tree) of your choice. |
| 2803 |
% Example (linux): |
| 2804 |
% \begin{quote} |
| 2805 |
% |unzip bitset.tds.zip -d ~/texmf| |
| 2806 |
% \end{quote} |
| 2807 |
% |
| 2808 |
% \subsection{Package installation} |
| 2809 |
% |
| 2810 |
% \paragraph{Unpacking.} The \xfile{.dtx} file is a self-extracting |
| 2811 |
% \docstrip\ archive. The files are extracted by running the |
| 2812 |
% \xfile{.dtx} through \plainTeX: |
| 2813 |
% \begin{quote} |
| 2814 |
% \verb|tex bitset.dtx| |
| 2815 |
% \end{quote} |
| 2816 |
% |
| 2817 |
% \paragraph{TDS.} Now the different files must be moved into |
| 2818 |
% the different directories in your installation TDS tree |
| 2819 |
% (also known as \xfile{texmf} tree): |
| 2820 |
% \begin{quote} |
| 2821 |
% \def\t{^^A |
| 2822 |
% \begin{tabular}{@{}>{\ttfamily}l@{ $\rightarrow$ }>{\ttfamily}l@{}} |
| 2823 |
% bitset.sty & tex/generic/bitset/bitset.sty\\ |
| 2824 |
% bitset.pdf & doc/latex/bitset/bitset.pdf\\ |
| 2825 |
% bitset.dtx & source/latex/bitset/bitset.dtx\\ |
| 2826 |
% \end{tabular}^^A |
| 2827 |
% }^^A |
| 2828 |
% \sbox0{\t}^^A |
| 2829 |
% \ifdim\wd0>\linewidth |
| 2830 |
% \begingroup |
| 2831 |
% \advance\linewidth by\leftmargin |
| 2832 |
% \advance\linewidth by\rightmargin |
| 2833 |
% \edef\x{\endgroup |
| 2834 |
% \def\noexpand\lw{\the\linewidth}^^A |
| 2835 |
% }\x |
| 2836 |
% \def\lwbox{^^A |
| 2837 |
% \leavevmode |
| 2838 |
% \hbox to \linewidth{^^A |
| 2839 |
% \kern-\leftmargin\relax |
| 2840 |
% \hss |
| 2841 |
% \usebox0 |
| 2842 |
% \hss |
| 2843 |
% \kern-\rightmargin\relax |
| 2844 |
% }^^A |
| 2845 |
% }^^A |
| 2846 |
% \ifdim\wd0>\lw |
| 2847 |
% \sbox0{\small\t}^^A |
| 2848 |
% \ifdim\wd0>\linewidth |
| 2849 |
% \ifdim\wd0>\lw |
| 2850 |
% \sbox0{\footnotesize\t}^^A |
| 2851 |
% \ifdim\wd0>\linewidth |
| 2852 |
% \ifdim\wd0>\lw |
| 2853 |
% \sbox0{\scriptsize\t}^^A |
| 2854 |
% \ifdim\wd0>\linewidth |
| 2855 |
% \ifdim\wd0>\lw |
| 2856 |
% \sbox0{\tiny\t}^^A |
| 2857 |
% \ifdim\wd0>\linewidth |
| 2858 |
% \lwbox |
| 2859 |
% \else |
| 2860 |
% \usebox0 |
| 2861 |
% \fi |
| 2862 |
% \else |
| 2863 |
% \lwbox |
| 2864 |
% \fi |
| 2865 |
% \else |
| 2866 |
% \usebox0 |
| 2867 |
% \fi |
| 2868 |
% \else |
| 2869 |
% \lwbox |
| 2870 |
% \fi |
| 2871 |
% \else |
| 2872 |
% \usebox0 |
| 2873 |
% \fi |
| 2874 |
% \else |
| 2875 |
% \lwbox |
| 2876 |
% \fi |
| 2877 |
% \else |
| 2878 |
% \usebox0 |
| 2879 |
% \fi |
| 2880 |
% \else |
| 2881 |
% \lwbox |
| 2882 |
% \fi |
| 2883 |
% \else |
| 2884 |
% \usebox0 |
| 2885 |
% \fi |
| 2886 |
% \end{quote} |
| 2887 |
% If you have a \xfile{docstrip.cfg} that configures and enables \docstrip's |
| 2888 |
% TDS installing feature, then some files can already be in the right |
| 2889 |
% place, see the documentation of \docstrip. |
| 2890 |
% |
| 2891 |
% \subsection{Refresh file name databases} |
| 2892 |
% |
| 2893 |
% If your \TeX~distribution |
| 2894 |
% (\TeX\,Live, \mikTeX, \dots) relies on file name databases, you must refresh |
| 2895 |
% these. For example, \TeX\,Live\ users run \verb|texhash| or |
| 2896 |
% \verb|mktexlsr|. |
| 2897 |
% |
| 2898 |
% \subsection{Some details for the interested} |
| 2899 |
% |
| 2900 |
% \paragraph{Unpacking with \LaTeX.} |
| 2901 |
% The \xfile{.dtx} chooses its action depending on the format: |
| 2902 |
% \begin{description} |
| 2903 |
% \item[\plainTeX:] Run \docstrip\ and extract the files. |
| 2904 |
% \item[\LaTeX:] Generate the documentation. |
| 2905 |
% \end{description} |
| 2906 |
% If you insist on using \LaTeX\ for \docstrip\ (really, |
| 2907 |
% \docstrip\ does not need \LaTeX), then inform the autodetect routine |
| 2908 |
% about your intention: |
| 2909 |
% \begin{quote} |
| 2910 |
% \verb|latex \let\install=y\input{bitset.dtx}| |
| 2911 |
% \end{quote} |
| 2912 |
% Do not forget to quote the argument according to the demands |
| 2913 |
% of your shell. |
| 2914 |
% |
| 2915 |
% \paragraph{Generating the documentation.} |
| 2916 |
% You can use both the \xfile{.dtx} or the \xfile{.drv} to generate |
| 2917 |
% the documentation. The process can be configured by the |
| 2918 |
% configuration file \xfile{ltxdoc.cfg}. For instance, put this |
| 2919 |
% line into this file, if you want to have A4 as paper format: |
| 2920 |
% \begin{quote} |
| 2921 |
% \verb|\PassOptionsToClass{a4paper}{article}| |
| 2922 |
% \end{quote} |
| 2923 |
% An example follows how to generate the |
| 2924 |
% documentation with pdf\LaTeX: |
| 2925 |
% \begin{quote} |
| 2926 |
%\begin{verbatim} |
| 2927 |
%pdflatex bitset.dtx |
| 2928 |
%makeindex -s gind.ist bitset.idx |
| 2929 |
%pdflatex bitset.dtx |
| 2930 |
%makeindex -s gind.ist bitset.idx |
| 2931 |
%pdflatex bitset.dtx |
| 2932 |
%\end{verbatim} |
| 2933 |
% \end{quote} |
| 2934 |
% |
| 2935 |
% \begin{History} |
| 2936 |
% \begin{Version}{2007/09/28 v1.0} |
| 2937 |
% \item |
| 2938 |
% First version. |
| 2939 |
% \end{Version} |
| 2940 |
% \begin{Version}{2011/01/30 v1.1} |
| 2941 |
% \item |
| 2942 |
% Already loaded package files are not input in \hologo{plainTeX}. |
| 2943 |
% \end{Version} |
| 2944 |
% \begin{Version}{2016/05/16 v1.2} |
| 2945 |
% \item |
| 2946 |
% Documentation updates. |
| 2947 |
% \end{Version} |
| 2948 |
% \begin{Version}{2019/12/09 v1.3} |
| 2949 |
% \item |
| 2950 |
% Documentation updates. |
| 2951 |
% \end{Version} |
| 2952 |
% \end{History} |
| 2953 |
% |
| 2954 |
% \PrintIndex |
| 2955 |
% |
| 2956 |
% \Finale |
| 2957 |
\endinput |