-- RTSetsImpl.mesa
-- Copyright (C) 1985 by Xerox Corporation. All rights reserved.
-- Last edited: July 31, 1984 4:11:47 pm PDT
DIRECTORY RTSets;
RTSetsImpl: CEDAR PROGRAM
EXPORTS RTSets =
BEGIN OPEN RTSets;
RTMdSetGenerateElement: PUBLIC PROCEDURE [i: INT]
RETURNS [RTMdSet] = {s: RTMdSet; s[i] ← TRUE; RETURN[s]};
RTMdSetGenerateInterval: PUBLIC PROCEDURE [i, j: INT]
RETURNS [RTMdSet] =
BEGIN
s: RTMdSet;
k: INT;
FOR k IN [i..j] DO s[k] ← TRUE ENDLOOP;
RETURN[s]
END;
RTMdSetAddElement: PUBLIC PROCEDURE [
i: INT, s: RTMdSet] RETURNS [RTMdSet] = {
s[i] ← TRUE; RETURN[s]};
RTMdSetAddInterval: PUBLIC PROCEDURE [
i, j: INT, s: RTMdSet] RETURNS [RTMdSet] =
BEGIN k: INT; FOR k IN [i..j] DO s[k] ← TRUE ENDLOOP; RETURN[s] END;
RTMdSetUnion: PUBLIC PROCEDURE [x, y: RTMdSet]
RETURNS [RTMdSet] =
BEGIN
s: RTMdSet;
i: RTMdSetRange;
FOR i IN RTMdSetRange DO s[i] ← x[i] OR y[i] ENDLOOP;
RETURN[s];
END;
RTMdSetIntersection: PUBLIC PROCEDURE [x, y: RTMdSet]
RETURNS [RTMdSet] =
BEGIN
s: RTMdSet;
i: RTMdSetRange;
FOR i IN RTMdSetRange DO s[i] ← x[i] AND y[i] ENDLOOP;
RETURN[s];
END;
RTMdSetDifference: PUBLIC PROCEDURE [x, y: RTMdSet]
RETURNS [RTMdSet] =
BEGIN
s: RTMdSet;
i: RTMdSetRange;
FOR i IN RTMdSetRange DO s[i] ← x[i] AND NOT y[i] ENDLOOP;
RETURN[s];
END;
RTMdSetIsSubset: PUBLIC PROCEDURE [x, y: RTMdSet]
RETURNS [BOOLEAN] =
BEGIN
i: RTMdSetRange;
FOR i IN RTMdSetRange DO
IF x[i] AND NOT y[i] THEN RETURN[FALSE] ENDLOOP;
RETURN[TRUE];
END;
RTMdSetIsSame: PUBLIC PROCEDURE [x, y: RTMdSet]
RETURNS [BOOLEAN] =
BEGIN
i: RTMdSetRange;
FOR i IN RTMdSetRange DO IF x[i] # y[i] THEN RETURN[FALSE] ENDLOOP;
RETURN[TRUE];
END;
RTMdSetCARD: PUBLIC PROCEDURE [x: RTMdSet]
RETURNS [INT] =
BEGIN
i: RTMdSetRange;
count: CARDINAL ← 0;
FOR i IN RTMdSetRange DO IF x[i] THEN count ← count + 1 ENDLOOP;
RETURN[count];
END;
RTLgSetGenerateElement: PUBLIC PROCEDURE [i: INT]
RETURNS [RTLgSet] = {s: RTLgSet; s[i] ← TRUE; RETURN[s]};
RTLgSetGenerateInterval: PUBLIC PROCEDURE [i, j: INT]
RETURNS [RTLgSet] =
BEGIN
s: RTLgSet;
k: INT;
FOR k IN [i..j] DO s[k] ← TRUE ENDLOOP;
RETURN[s]
END;
RTLgSetAddElement: PUBLIC PROCEDURE [i: INT, s: RTLgSet]
RETURNS [RTLgSet] = {s[i] ← TRUE; RETURN[s]};
RTLgSetAddInterval: PUBLIC PROCEDURE [
i, j: INT, s: RTLgSet] RETURNS [RTLgSet] =
BEGIN k: INT; FOR k IN [i..j] DO s[k] ← TRUE ENDLOOP; RETURN[s] END;
RTLgSetUnion: PUBLIC PROCEDURE [x, y: RTLgSet]
RETURNS [RTLgSet] =
BEGIN
s: RTLgSet;
i: RTLgSetRange;
FOR i IN RTLgSetRange DO s[i] ← x[i] OR y[i] ENDLOOP;
RETURN[s];
END;
RTLgSetIntersection: PUBLIC PROCEDURE [x, y: RTLgSet]
RETURNS [RTLgSet] =
BEGIN
s: RTLgSet;
i: RTLgSetRange;
FOR i IN RTLgSetRange DO s[i] ← x[i] AND y[i] ENDLOOP;
RETURN[s];
END;
RTLgSetDifference: PUBLIC PROCEDURE [x, y: RTLgSet]
RETURNS [RTLgSet] =
BEGIN
s: RTLgSet;
i: RTLgSetRange;
FOR i IN RTLgSetRange DO s[i] ← x[i] AND NOT y[i] ENDLOOP;
RETURN[s];
END;
RTLgSetIsSubset: PUBLIC PROCEDURE [x, y: RTLgSet]
RETURNS [BOOLEAN] =
BEGIN
i: RTLgSetRange;
FOR i IN RTLgSetRange DO
IF x[i] AND NOT y[i] THEN RETURN[FALSE] ENDLOOP;
RETURN[TRUE];
END;
RTLgSetIsSame: PUBLIC PROCEDURE [x, y: RTLgSet]
RETURNS [BOOLEAN] =
BEGIN
i: RTLgSetRange;
FOR i IN RTLgSetRange DO IF x[i] # y[i] THEN RETURN[FALSE] ENDLOOP;
RETURN[TRUE];
END;
RTLgSetCARD: PUBLIC PROCEDURE [x: RTLgSet]
RETURNS [INT] =
BEGIN
i: RTLgSetRange;
count: CARDINAL ← 0;
FOR i IN RTLgSetRange DO IF x[i] THEN count ← count + 1 ENDLOOP;
RETURN[count];
END;
END. -- RTSetsImpl