G3dNats.mesa
Copyright Ó 1984, 1992 by Xerox Corporation. All rights reserved.
Glassner, February 18, 1991 8:08 pm PST
Jules Bloomenthal August 26, 1992 3:21 pm PDT
DIRECTORY G2dBasic, Rope;
G3dNats: CEDAR DEFINITIONS
~ BEGIN
Basic Types
ROPE:       TYPE ~ Rope.ROPE;
IntegerPairSequence:  TYPE ~ G2dBasic.IntegerPairSequence;
NatSequence:     TYPE ~ G2dBasic.NatSequence;
NatTable:      TYPE ~ REF NatTableRep;
NatTableRep:     TYPE ~ RECORD [
length:        CARDINAL ¬ 0,
element:        SEQUENCE maxLength: CARDINAL OF NatSequence];
NatSequence Support Procs
NewNatSequence3: PROC [v0, v1, v2: INT] RETURNS [NatSequence];
Return a new NatSequence containing these three elements (useful to make triangles)
EqualNatSequences: PROC [s1, s2: NatSequence] RETURNS [BOOL];
RETURN TRUE iff s1.length=s2.length and i: s1[i]=s2[i]
GetCommonElementInNatSequences: PROC [n1, n2: NatSequence] RETURNS [INT];
Get an element shared by both sequences, or -1 if none shared (uses a dumb n2 test)
GetNatSequenceIndex: PROC [nats: NatSequence, nat: NAT] RETURNS [INT];
Return index into sequence where nat appears, else -1
ReplaceNatInSequence: PROC [n: NatSequence, old, new: NAT] RETURNS [NatSequence];
Return a new sequence where all occurences of old are replaced with new
RemoveNatInSequence: PROC [n: NatSequence, old: NAT] RETURNS [NatSequence];
Return a new NatSequence with all occurances of old deleted
GetUniqueElement: PROC [ns: NatSequence] RETURNS [INT];
Returns the unrepeated element in ns, raises an error if 0 or >1 unrepeated elements found
GetRepeatedElement: PROC [ns: NatSequence] RETURNS [INT];
Return the first element in the list that repeats an earlier element, else -1
GetElementNotShared: PROC [v: NAT, ns: NatSequence] RETURNS [INT];
Returns the single element in ns that is not v. If 0 or more such elements, returns -1
NatInSequence: PROC [nat: NAT, seq: NatSequence] RETURNS [BOOL];
Returns TRUE iff nat is in seq.
NatSequenceLength: PROC [seq: NatSequence] RETURNS [INT];
IF seq = NIL THEN RETURN[0] ELSE RETURN [seq.length];
NatTable Operations
CopyNatSequenceSequence: PUBLIC PROC [nats: NatTable] RETURNS [NatTable];
AddToNatSequenceSequence: PUBLIC PROC [nats: NatTable, nat: NatSequence]
RETURNS [NatTable];
LengthenNatSequenceSequence: PUBLIC PROC [nats: NatTable, amount: REAL ¬ 1.3]
RETURNS [new: NatTable];
Scratch Pool
ObtainScratchNats: PROC [length: INTEGER] RETURNS [NatSequence];
Return a scratch sequence from a pool.
ReleaseScratchNats: PROC [scratch: NatSequence];
Return nats to the scratch pool.
ObtainScratchIntegerPairs: PROC [length: INTEGER] RETURNS [IntegerPairSequence];
Return a scratch sequence from a pool.
ReleaseScratchIntegerPairs: PROC [scratch: IntegerPairSequence];
Return nats to the scratch pool.
END.