<> <> <> DIRECTORY CD; CDLRUCache: CEDAR DEFINITIONS = BEGIN LRUCache: TYPE = REF LRUCacheRep; LRUCacheRep: TYPE; AequivalenceProc: TYPE = PROC[mySpecific, other: REF ANY] RETURNS [BOOL]; NewProc: TYPE = PROC [] RETURNS [CD.ObPtr]; Create: PROC [size: CARDINAL _ 17, aequivalenceProc: AequivalenceProc_NIL, newProc: NewProc_NIL] RETURNS [LRUCache]; <<--creates new LRU cache of suggested size>> <<--aequivalenceProc: procedure to check specificRef's for aequivalence>> <<-- NIL means: aeqivalence if same REF's>> <<--newProc: Procedure to allocate new objects; >> <<-- NIL means: UnusedOrNew will never be called on this LRUCache>> UnusedOrNew: PROC [lruCache: LRUCache] RETURNS [CD.ObPtr]; <<--this procedure is defined only if Create of lruCache had a NewProc>> <<--before allocating a new object with the newProc, it tries if>> ReplaceByAequivalent: PROC [lruCache: LRUCache, ob: CD.ObPtr] RETURNS [CD.ObPtr]; <<--returns either "ob" or an aequivalent object to "ob">> <<--side effect: introduces "ob" in aequivalence table to be accessed by others.>> <<--consider "ob" immutable! respectively, on any further change, it may cause>> <<--the same change made to all or some aequivalent objects in past and future >> END.