| 1 |
(* Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. *) |
| 2 |
(* This file is part of GNU Modula-2. |
| 3 |
|
| 4 |
GNU Modula-2 is free software; you can redistribute it and/or modify it under |
| 5 |
the terms of the GNU General Public License as published by the Free |
| 6 |
Software Foundation; either version 2, or (at your option) any later |
| 7 |
version. |
| 8 |
|
| 9 |
GNU Modula-2 is distributed in the hope that it will be useful, but WITHOUT ANY |
| 10 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 |
for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License along |
| 15 |
with gm2; see the file COPYING. If not, write to the Free Software |
| 16 |
Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *) |
| 17 |
|
| 18 |
MODULE largeset3 ; |
| 19 |
|
| 20 |
FROM libc IMPORT exit ; |
| 21 |
FROM NumberIO IMPORT WriteCard ; |
| 22 |
FROM StrIO IMPORT WriteString, WriteLn ; |
| 23 |
|
| 24 |
TYPE |
| 25 |
LargeBitset = SET OF [0..127] ; |
| 26 |
|
| 27 |
|
| 28 |
VAR |
| 29 |
b: LargeBitset ; |
| 30 |
j: CARDINAL ; |
| 31 |
BEGIN |
| 32 |
j := 1 ; |
| 33 |
b := LargeBitset{} ; |
| 34 |
WriteString('index = ') ; WriteCard(1, 2) ; WriteLn ; |
| 35 |
INCL(b, 1) ; |
| 36 |
IF NOT (1 IN b) |
| 37 |
THEN |
| 38 |
exit(3) |
| 39 |
END ; |
| 40 |
IF 1 IN b |
| 41 |
THEN |
| 42 |
INC(j) |
| 43 |
ELSE |
| 44 |
exit(4) |
| 45 |
END ; |
| 46 |
|
| 47 |
EXCL(b, 1) ; |
| 48 |
IF b#LargeBitset{} |
| 49 |
THEN |
| 50 |
exit(2) |
| 51 |
END ; |
| 52 |
|
| 53 |
j := 20 ; |
| 54 |
b := LargeBitset{} ; |
| 55 |
WriteString('index = ') ; WriteCard(20, 2) ; WriteLn ; |
| 56 |
INCL(b, 20) ; |
| 57 |
IF NOT (20 IN b) |
| 58 |
THEN |
| 59 |
exit(3) |
| 60 |
END ; |
| 61 |
IF 20 IN b |
| 62 |
THEN |
| 63 |
INC(j) |
| 64 |
ELSE |
| 65 |
exit(4) |
| 66 |
END ; |
| 67 |
|
| 68 |
EXCL(b, 20) ; |
| 69 |
IF b#LargeBitset{} |
| 70 |
THEN |
| 71 |
exit(2) |
| 72 |
END ; |
| 73 |
|
| 74 |
j := 40 ; |
| 75 |
b := LargeBitset{} ; |
| 76 |
WriteString('index = ') ; WriteCard(40, 2) ; WriteLn ; |
| 77 |
INCL(b, 40) ; |
| 78 |
IF NOT (40 IN b) |
| 79 |
THEN |
| 80 |
exit(3) |
| 81 |
END ; |
| 82 |
IF 40 IN b |
| 83 |
THEN |
| 84 |
INC(j) |
| 85 |
ELSE |
| 86 |
exit(4) |
| 87 |
END ; |
| 88 |
|
| 89 |
EXCL(b, 40) ; |
| 90 |
IF b#LargeBitset{} |
| 91 |
THEN |
| 92 |
exit(2) |
| 93 |
END ; |
| 94 |
|
| 95 |
j := 60 ; |
| 96 |
b := LargeBitset{} ; |
| 97 |
WriteString('index = ') ; WriteCard(60, 2) ; WriteLn ; |
| 98 |
INCL(b, 60) ; |
| 99 |
IF NOT (60 IN b) |
| 100 |
THEN |
| 101 |
exit(3) |
| 102 |
END ; |
| 103 |
IF 60 IN b |
| 104 |
THEN |
| 105 |
INC(j) |
| 106 |
ELSE |
| 107 |
exit(4) |
| 108 |
END ; |
| 109 |
|
| 110 |
EXCL(b, 60) ; |
| 111 |
IF b#LargeBitset{} |
| 112 |
THEN |
| 113 |
exit(2) |
| 114 |
END ; |
| 115 |
|
| 116 |
j := 100 ; |
| 117 |
b := LargeBitset{} ; |
| 118 |
WriteString('index = ') ; WriteCard(100, 3) ; WriteLn ; |
| 119 |
INCL(b, 100) ; |
| 120 |
IF NOT (100 IN b) |
| 121 |
THEN |
| 122 |
exit(3) |
| 123 |
END ; |
| 124 |
IF 100 IN b |
| 125 |
THEN |
| 126 |
INC(j) |
| 127 |
ELSE |
| 128 |
exit(4) |
| 129 |
END ; |
| 130 |
|
| 131 |
EXCL(b, 100) ; |
| 132 |
IF b#LargeBitset{} |
| 133 |
THEN |
| 134 |
exit(2) |
| 135 |
END |
| 136 |
|
| 137 |
END largeset3. |