FilePageMgrRedBlackTreeImpl.mesa
Copyright © 1985 by Xerox Corporation. All rights reserved.
Hauser, March 27, 1985 11:57:01 am PST
A thin interface over RedBlackTree handling the coercions. Should be called only from FilePageMgrMainImpl with the lock in fpmFileHandle already held. This is split out only to overcome compile size restriction.
FPMFileHandle: TYPE = REF FPMFileObject;
FPMFileObject: TYPE = FpmPF.FPMFileObject;
RefChunk: TYPE = REF Chunk;
Chunk: TYPE = FpmPC.Chunk;
LookupProc: TYPE = FilePageMgrRedBlackTree.LookupProc;
Lookup: PUBLIC LookupProc = {
fpmFileHandle.rbKeyRef^ ← key;
RETURN[ NARROW[RedBlackTree.Lookup[ fpmFileHandle.chunkTable, fpmFileHandle.rbKeyRef]] ];
};
LookupNextLarger: PUBLIC LookupProc = {
fpmFileHandle.rbKeyRef^ ← key;
RETURN[ NARROW[RedBlackTree.LookupNextLarger[ fpmFileHandle.chunkTable, fpmFileHandle.rbKeyRef]] ];
};
LookupNextSmaller: PUBLIC LookupProc = {
fpmFileHandle.rbKeyRef^ ← key;
RETURN[ NARROW[RedBlackTree.LookupNextSmaller[ fpmFileHandle.chunkTable, fpmFileHandle.rbKeyRef]] ];
};
LookupLargest: PUBLIC PROCEDURE[ fpmFileHandle: FPMFileHandle ] RETURNS [RefChunk] = {
RETURN[ NARROW[RedBlackTree.LookupLargest[ fpmFileHandle.chunkTable]] ];
};
LookupSmallest: PUBLIC PROCEDURE[ fpmFileHandle: FPMFileHandle ] RETURNS [RefChunk] = {
RETURN[ NARROW[RedBlackTree.LookupSmallest[ fpmFileHandle.chunkTable ]] ];
};
Delete: PUBLIC PROCEDURE[ fpmFileHandle: FPMFileHandle, key: AlpineEnvironment.PageNumber ] RETURNS [RefChunk] = {
n: RedBlackTree.Node;
fpmFileHandle.rbKeyRef^ ← key;
n ← RedBlackTree.Delete[ fpmFileHandle.chunkTable, fpmFileHandle.rbKeyRef];
RETURN[ IF n=NIL THEN NIL ELSE NARROW[n.data] ];
};
Insert: PUBLIC PROCEDURE[ fpmFileHandle: FPMFileHandle, refChunk: RefChunk, key: AlpineEnvironment.PageNumber ] = {
fpmFileHandle.rbKeyRef^ ← key;
RedBlackTree.Insert[ fpmFileHandle.chunkTable, refChunk, fpmFileHandle.rbKeyRef ];
};