OrderedRefArray: CEDAR DEFINITIONS = BEGIN Ref: TYPE = REF Rep; Rep: TYPE; -- Opaque Index: TYPE = [1..LAST[INTEGER]]; OutOfRange: ERROR[index: Index]; PruneMethodTypes: TYPE = {firstValue, lastValue, firstValueIfFilled, lastValueIfFilled}; PruneMethod: PruneMethodTypes; --Initialized to lastValueIfFilled EachItemAction: TYPE = PROC[itemIndex: Index, item: REF, value: INT] RETURNS [quit: BOOL _ FALSE]; Create: PROC [maxSize: Index] RETURNS [Ref]; -- maxSize is max number of items to collect Copy: PROC[oArray: Ref] RETURNS [Ref]; -- Copies 1 level only => shares item Size: PROC [oArray: Ref] RETURNS [NAT]; MaxSize: PROC[oArray: Ref] RETURNS [Index]; Insert: PROC[oArray: Ref, item: REF, value: INT]; InsertCheck: PROC[oArray: Ref, item: REF, value: INT] RETURNS [BOOL]; Enumerate: PROC[oArray: Ref, action: EachItemAction, increasing: BOOL _ TRUE]; Fetch: PROC[oArray: Ref, at: Index] RETURNS [item: REF, value: INT]; GetPruneValue: PROC[oArray: Ref] RETURNS [INT]; GetInsertionCount: PROC[oArray: Ref] RETURNS [INT]; END. @--File: OrderedRefArray.mesa Last Edited by: CSChow, February 1, 1985 0:23:15 am PST --NB: `Array' here is use in the Cedar sense, ie. fixed size -- Intro: This is a non-Standard interface. It is used to collect results from searches. -- It was meant to be quick and simple and so may not be the most general one. -- It makes the uniform assumption that item of smallest value is of the most desirable -- as far as prunning is concerned -- Impl: List of ref any with head and tail pointers --Only Affects GetPruneValue below. See OrderedRefArrayImpl.GetPruneValue -- This is a global switch that affects all instances. --eg. change PruneMethod from program or interpter -- values determines ordering of item. -- smallest at the beginning (index = 1) and most desirable --Insert is going to insert item iff InsertCheck = TRUE --! ERROR OutOfRange[at] -- IF oArray is Filled THEN return value of worst item kept -- ELSE return LAST[INT] --Counts #calls to Insert on oArray -- Count is from 1 to LAST[INT] and wrap around to FIRST[INT] -- Introduced for statistics gathering ΚM˜J™J™7J™J™K™&—J˜Jšœ˜——…— ©