General
ROPE: TYPE = Rope.ROPE;
Cant: ERROR [data: REF ANY, msg: ROPE];
Comparison: TYPE = {less, equal, greater, noComparison};
Elements
Element: TYPE = REF ElementPrivate;
ElementPrivate:
TYPE =
RECORD [
class: ElementClass,
data: REF ANY];
ElementClass: TYPE = REF ElementClassPrivate;
ElementClassPrivate:
TYPE =
RECORD [
data: REF ANY ← NIL,
Equal: PROC [e1, e2: Element] RETURNS [equal: BOOL] ← NIL,
anOrder: TotalOrder ← NIL
];
MakeElementClass:
PROC [ElementClassPrivate]
RETURNS [ElementClass];
Provides default implementations, where appropriate.
Sets
Set: TYPE = REF SetPrivate;
SetPrivate:
TYPE =
RECORD [
class: SetClass,
mutable:
BOOL,
Tells whether this is actually a set variable or a set.
data: REF ANY];
Enumerator: TYPE = Set--able to Enumerate--;
Filter: TYPE = Set--able to TestMembership--;
SetClass: TYPE = REF SetClassPrivate;
SetClassPrivate:
TYPE =
RECORD [
data: REF ANY ← NIL,
Size: PROC [set: Set] RETURNS [INT] ← NIL,
Enumerate: PROC [set: Set, consumer: PROC [Element]] ← NIL,
TestMembership: PROC [set: Set, element: Element] RETURNS [BOOL] ← NIL,
AddElement: PROC [set: Set, element: Element] ← NIL,
DeleteElement: PROC [set: Set, element: Element] ← NIL,
Copy: PROC [set: Set] RETURNS [Set] ← NIL,
Freeze:
PROC [set: Set]
RETURNS [
--same--Set] ←
NIL
Change a set variable into a set.
];
Enumerate:
PROC [set: Set, consumer:
PROC [Element]]
= INLINE {set.class.Enumerate[set, consumer]};
EnumerateNI:
PROC [set: Set, consumer:
PROC [Element]];
A non-INLINE version of Enumerate.
TestMembership:
PROC [set: Set, element: Element]
RETURNS [
BOOL]
= INLINE {RETURN [set.class.TestMembership[set, element]]};
TestMembershipNI: PROC [set: Set, element: Element] RETURNS [BOOL];
AddElement:
PROC [set: Set, element: Element]
= INLINE {set.class.AddElement[set, element]};
AddElementNI: PROC [set: Set, element: Element];
MakeSetClass:
PROC [SetClassPrivate]
RETURNS [SetClass];
Provides default implementations, where appropriate.
Sequences
Sequence: TYPE = REF SequencePrivate;
SequencePrivate:
TYPE =
RECORD [
class: SequenceClass,
mutable: BOOL,
data: REF ANY];
SequenceClass: TYPE = REF SequenceClassPrivate;
SequenceClassPrivate:
TYPE =
RECORD [
data: REF ANY ← NIL,
Length: PROC [seq: Sequence] RETURNS [INT] ← NIL,
Range: PROC [seq: Sequence] RETURNS [set: Set] ← NIL,
Fetch: PROC [seq: Sequence, index: INT--[0..Length)--] RETURNS [Element] ← NIL,
Assign: PROC [seq: Sequence, first, last: INT, element: Element] ← NIL,
Insert: PROC [seq: Sequence, before: INT, element: Element] ← NIL,
Delete: PROC [seq: Sequence, first, last: INT] ← NIL,
Subsequence: PROC [seq: Sequence, first: INT ← 0, length: INT ← LAST[INT]] RETURNS [Sequence] ← NIL,
Copy: PROC [seq: Sequence] RETURNS [Sequence] ← NIL,
Freeze: PROC [seq: Sequence] RETURNS [--same--Sequence] ← NIL
];
Functions
Function: TYPE = REF FunctionPrivate;
FunctionPrivate:
TYPE =
RECORD [
class: FunctionClass,
mutable: BOOL,
data: REF ANY];
FunctionClass: TYPE = REF FunctionClassPrivate;
FunctionClassPrivate:
TYPE =
RECORD [
data: REF ANY ← NIL,
Size: PROC [fn: Function] RETURNS [INT] ← NIL,
QuaSet: PROC [fn: Function] RETURNS [set: Set--of 2-long Sequence--] ← NIL,
Invert:
PROC [fn: Function]
RETURNS [inv: Function] ←
NIL,
inv[y] = {x | fn[x] = y}
Domain: PROC [fn: Function] RETURNS [set: Set] ← NIL,
Range: PROC [fn: Function] RETURNS [set: Set] ← NIL,
Apply: PROC [fn: Function, arg: Element] RETURNS [Element] ← NIL,
Assign: PROC [fn: Function, arg, result: Element] ← NIL,
Delete: PROC [fn: Function, arg: Element] ← NIL,
Copy: PROC [fn: Function] RETURNS [Function] ← NIL,
Freeze: PROC [fn: Function] RETURNS [--same--Function] ← NIL
];
Dictionary: TYPE = Function--whose domain is ROPEs--;
Orders
Order: TYPE = REF OrderPrivate;
OrderPrivate:
TYPE =
RECORD [
class: OrderClass,
mutable: BOOL,
data: REF ANY];
OrderClass: TYPE = REF OrderClassPrivate;
OrderClassPrivate:
TYPE =
RECORD [
data: REF ANY ← NIL,
Compare: PROC [o: Order, e1, e2: Element] RETURNS [c: Comparison],
Copy: PROC [fn: Order] RETURNS [Order] ← NIL,
Freeze: PROC [fn: Order] RETURNS [--same--Order] ← NIL
];
TotalOrder:
TYPE = Order;
Whose Compare never returns noComparison.
}.