OrderedSymbolTableRef.mesaOrderedSymbolTableRefisavariantoftheOrderedSymbolTablepackageformaintainingsymboltables(keytovaluemaps)withaninterestingorderingamongkeys.ThepackagestoresREFANYitems,andacceptsanitem-comparisonprocedureasaparameteratthetimeatableiscreated,soitdoesnotneedtoberecompiledtohandledifferenttypesofitems.Lasteditedby:MBrownonNovember17,198210:45amDIRECTORYEnvironmentUSING[Comparison];OrderedSymbolTableRef:CEDARDEFINITIONS=BEGINTable:TYPE=REFTableObject;TableObject:TYPE;Key,Item:TYPE=REFANY;Comparison:TYPE=Environment.Comparison;CompareProc:TYPE=PROC[r1,r2:Item]RETURNS[Comparison];ProceduresCreateTable:PROC[compareProc:CompareProc,nodeZone:ZONE_NIL,tableZone:ZONE_NIL]RETURNS[t:Table];Returnsanemptytablethatusesthegivencomparisonfunction.nodeZonewillbeusedtoallocatenodesforred-blacktree(7wordseach),tableZonewillbeusedtoallocateheaderfortree(11wordsplus3nodes);thesebothdefaulttothesystemzone.DestroyTable:PROC[t:Table];Deletesallitemsfromt,theninvalidatest.DeleteAllItems:PROC[t:Table];Makestabletempty(t.Size[]=0).Size:PROC[t:Table]RETURNS[nItems:INT];Returnsthenumberofitemsint.Insert:PROC[t:Table,insertItem:Item];Insertsitemxintotablet.ERRORsDuplicateKey(withmonitorreleased)ifcompareProc[x,y]=equalforsomeyinthetable.DuplicateKey:ERROR;Delete:PROC[t:Table,deleteKey:Item]RETURNS[deletedItem:Item];Removesthe(unique)itemyintsuchthatcompareProc[deleteKey,y]=equal,andreturnsit,orreturnsNILifnosuchitemispresent.Lookup:PROC[t:Table,lookupKey:Key]RETURNS[equalItem:Item];Returnsthe(unique)itemyintsuchthatcompareProc[lookupKey,y]=equal,orNILifnosuchitemexists.LookupSmallest:PROC[t:Table]RETURNS[smallestItem:Item];Returnstheitemintabletwithsmallestkey,orNILiftisempty.LookupNextLarger:PROC[t:Table,lookupKey:Key]RETURNS[largerItem:Item];ReturnstheitemintabletwiththesmallestkeystrictlylargerthanlookupKey,orNILifnosuchitemexists.Lookup3:PROC[t:Table,lookupKey:Key]RETURNS[leftItem,equalItem,rightItem:Item];ThisLookupprocedurereturnsthreenodesintable:[LookupNextSmaller[self,lookupKey],1pî ìïa¶qî ìï]†îïî}îÔî Œî"Rî$Àî1»î7 î9j îA îE·î ìï[ßî îÛîˆî£îÂîØ î"‘î(î,›î0Íî3³î9rî=ï[ßî=Òï[ßî?ÊqîBÂï[ßîC%ï[ßîFÊî ìïZ8î™î�î²î àî"�î#Õî*2î+Úî.)î15î2mî5Äî73î<8î=õî?PîBWîD¾îGêî ìïX�î ¼ î‚î'î…îãî!Mî"ðî ýïVßîîîïU-îµî¨î îIî!Žî%Nsî ýïQÊtîïP sî_ïPîDïPtîŽïPîñïP î ýïLµsîúïLµîÅïLµî u tî({ïLµsî*`ïLµî+ïLµtîïKsîhïKî"ïKtîÀïKsî¥ïKîyïKtîUïKî<ïK îïIR sîUïIRîïIRtîBïIRîïG¡îasî!ïG¡îÚïG¡tîxïG¡sî]ïG¡î1ïG¡î tî�ïG¡îïEï sîIïEïîïEïtî ïEïî…ïEïîïD> sî1ïD>îêïD>tîˆïD>sîmïD>îïD>tîúïD>î ]ïD>î"nî$ sî(JïD>î)ïD>tî.;ïD>î.žïD> pî ìï?: uî ýï; tîFï; sîDï; îìï; tîÑï; î4ï; î ô î)õsî0ðï; î1©ï; tî4‘ï; sî6ï; î7ï; tî8)ï; î9ï; sî?öï; î@¯ï; tîC—ï; sîE$ï; îF ï; tîG0ï; sî Ðï9ctîÁï9cî$ï9cî‘qîï7±îîîîaî3î"î$cî'ï î/î58î;~î>î?âîBóîáï6 îãî¦îÍîÀî"oî$î'òî+ëî2Eî4Úî6ªî9ºî;_î@aîD½îáï4cî�îîîÃîœîÑî! î$vî'ˆî,î-«î/÷î4Kuî ýï2± tîï2±sîÿï2±î¦ï2±tî‹ï2±îîï2±î[qîï0ÿîÎîÉîVî”îàîë î&“uî ýï/N tîÝï/NsîÚï/Nî‚ï/Ntîgï/NîÊï/Nî7qîï-œî~îÑîÅîÀîØî!½uî ýï*9tî}ï*9sîzï*9î"ï*9tîï*9îjï*9î×sîï*9îïï*9tî ï*9îoï*9sî$zï*9î$äï*9tî&…ï*9î&èï*9qîï(ˆîîkîPîôî�î!&uî ýï&Ötîoï&Ösîlï&Öîï&Ötîùï&Öî\ï&ÖîÉî î!qîï%%î„îŒîØîžîñîÂî$Ê î-5î0ªî5»î;Vî<¬ îFVîáï#}îÆîfîŽîøî!îÇîuî ýï!Ì tîï!Ìsîÿï!Ìî¸ï!Ìtîï!Ìuî ýï tîÞï sîÛï îƒï tîhï îËï î7îp î!nsî%ï î%ëï tî+ ï î+lï  î3|qîïiî¬îøîUî]î‡î!-î""î%?î(î6�î8(î: î>î@©îE@îFðîáïÁîyîžîõîèîî î!yuî ýï^tî‚ï^sî€ï^î(ï^tî ï^îpï^îÜî î"¬sî& ï^î&Þï^tî+ûï^î,^ï^ î3Zqîï­îîkîÉîÑîûî ¡î!•î$²î'„î6¨î8?î:$î>î?ÕîBûîDQîFDîáïîêuî ýïT tî—ïTsî•ïTî<ïTtî!ïTî…ïTîñsî 5ïTî! ïTtî&&ïTî&‰ïT î.ûqîï¢îîkîtîîmîaî!]î&‚î)erî+ï¢î+ûï¢qî-£ï¢î.ï¢î.ùî/îî1Yuî ýïñtîfïñsîcïñî ïñtîðïñîSïñîÀî!ù î)�sî,îïñî-Âïñtî2ßïñî3Bïñ î:iqîï?îîkîtîîmîaî!]î#©î(Îî+Yî/Íî3¹î6Ù î=örî?¯ï?î@Œï?qîB4ï?îB—ï?îCŠîE}îáï ˜îêuî ýï ætî3ï æsî0ï æîØï ætî½ï æî ï æî�îÆ î#]sî&ºï æî'Žï ætî,¬ï æî-ï æî2ž î9y î@qîï 5îî*îVî íî$Yî(î)Áî-Žî=- vî)ÈïöáTVm$äLookup[self,lookupKey],LookupNextLarger[self,lookupKey]].Notethatinanonemptytable,oneoftheresultsisguaranteed#NIL.(ThisprocedurewasHowardSturgis'idea.)EnumerateIncreasing:PROC[t:Table,procToApply:PROC[Item]RETURNS[BOOLEAN]];Foreachitemxinthetable,inincreasingorderbykeyvalue,executesprocToApply[x].ReturnswhenprocToApplyreturnsTRUEorwhenallitemshavebeenenumerated.TheprocedureprocToApplymaymakeanymodificationstothetablethatitlikes;EnumerateIncreasingisimplementedtosimulateonecallonLookupSmallest(tofindthefirstitem),andthenrepeatedcallstoLookupNextLarger(tofindthe"next"item),somodificationstothetableduringtheenumerationmaybeunderstoodintermsofthismodel.CheckTable:PROC[t:Table];ERRORsError[badTable]ifthered-blacktreerepresentingthetableisnotwell-formed.Usedbypackagetestprograms;maybeusedforclientdebuggingofunsafeprograms.BadTable:ERROR;RootItem:PROC[t:Table]RETURNS[rootItem:Item];Returnsthetherootofthered-blacktreerepresentingthetable.Usedbypackagetestprogramsonly.END.OrderedSymbolTablesHowtoacquirethepackageBringover/a/pTop>RedBlackTreeRef.dftoobtaintheinterfaceOrderedSymbolTableRef.bcdandtheimplementationRedBlackTreeRefImpl.bcd.Ifyoubindtheimplementationintoyourownconfiguration,you'llhavetoimportSafeStorageforitsuse.WritingCompareProcsThispackagetriestobeasgeneralaspossible,andhencetradessomeefficiencyforflexiblilty.ThepackagestoresREFANYitems,andperformscomparisonswithauser-suppliedprocedurecalledaCompareProc.ACompareProcmustbepreparedbothtocomparetwoitems(asinInsert,whereitcomparesinsertItemwithitemsalreadyinthetable),andtocompareakeytoanitem(asinLookup,whereitcompareslookupKeywithitemsalreadyinthetable).Onewayfortheclienttoaccomplishthisistomakekeysanditemsthesame,thatis,toembedakeyintoanitembeforecallingLookup.ThissimplifiestheCompareProcattheexpenseofcomplicatingthecallersofLookup.ThealternativeistoimplementaCompareProcthatispreparedtoseeabarekey(suchasaREFINToraROPE)asitsfirstargument.Thesecondargumenttoatable'sCompareProcisguaranteedtobeanitemstoredinthetable.Thereisnolawthatsaysthatallitemsinatablemusthavethesametype.Asyouaddvariabilitytoitemtypes,youaddcomplexitytotheCompareProc.CallingaCompareProccostsoneprocedurecall,plusthecostoftwoREFANYdiscriminations,plusthecostofactuallydoingthecomparison.Ifthecostofacomparisonishighanywaythenthisoverheadisprobablyacceptable.Ifcomparisonsaresimpleandefficiencyisimportant,youshouldbeusingtheOrderedSymbolTablepackage.ConcurrencyThetablesmaintainedbythispackageareobjectmonitors,soindividualcalls(excepttoEnumerateIncreasing)areatomic.2qîáïb& î¥ î0î,Ñ î5Nî8¢î;sî=î>NîDwîáï`îoîî_î›î î!òrî#×ï`î$³ï`qî%òï`î'Sï`î*Üî1î3¨î8Òî=Ôuî ýï]*tî„ï]*sî‚ï]*î)ï]*tîï]*îqï]*îÞî# sî,ï]*î,ªï]*tî/�ï]*î/òï]*sî3œï]*î4pï]*tî9�ï]*sî9ðï]*tî?�ï]*î?óï]*qîï[î¤îËîÓîîÅîî¼î!b î'Éî+Qî-+î/·î3™î9îC„îáïYØîc îfrîþïYØî·ïYØqî"ŠïYØî#;ïYØî$Cî'Åî)Àî-Mî0tî3� îïX-îÒîý îî!ðî%�î(5 î0wî2î4hî7»î:�î;åîáïV†îÞîJ î%!î&Æî,#î.±î1Gî3: î=>î?]îB"îDnîáïTÞî»î_îiîÄî Þî"ƒî.lî0Šî3Oî5›î:î=ëî?¤ îGæîáïS7î-î�îÈî î"Öî%Çî'– î.kî0î3¿î5bî7ûuî ýïOâ tîïOâsî ïOâî´ïOâtî™ïOâîüïOâîirîïN7qîïN7îïN7îÿîUî ¡î&”î)B î0Õî3!î6uî7àî:D îBkîEÒîáïL�î$î¨î îúî!Éî$Úî'î*±î1 î2Äî7uî ýïJåtî®ïJåsî¬ïJåîeïJåtî½ïJåuî ýïI;tî¡ïI;sîŸïI;îGïI;tî,ïI;î�ïI;îûsî?ïI;îïI;tî"0ïI;î"”ïI;î(½qîïG�îîkî·î‘î4î€î$sî'" î.µî1î51î8˜î:rî?µîB8îáïEésî ýïD>tî…ïD>pî ìï?DîWî&wî ìï;î ÙîÝî§î€qî ìï7Éî#îîìî(î)¼î-ãî0.î5¸îFëî ìï6"î  îî&î'Žî* î,õî/& î8ˆî;4î>3î@ó î ìï4{î ¡îÈîmîÀ îXî €î"[wî ìï0Tî qî ìï-î æîîøî†î@îãîŽî 1î%rî(î+ºî/�î2ñ î8Òî:ä îAŸîDLî ìï+Zrî ¹ï+Zî„ï+Zî`qî<ï+ZîŸï+Zî!îÅîV î&üî)÷î+, î3=î9iî=Jî>~ î ìï(Üî ~ î îhîGîÛî!üî#±î)&î+Âî/^î1 î3Vî7¯î;¡î=xîCï(ÜîCeï(Üqî ìï'4î îÜîÍî§î&îî!Vî#/î(Èî*1î,ðî.Èî0ïî4,î6’î8kî>îBîC¥xî ìï%�qîï%�îçï%�îòîtî(îÃî î$›î'‚î*9î,Wî.™î2>î3Ù î:¸î=Fî>¨î@CîCåîFëî ìï#æî ]îŽî5îëî”îî2îLî ¼î#gî%?î(,î,î0kî6î9 î>ßîA î ìï">î ‰î ÎîÕîq îTî˜î"Êî$fî*?î,û î3“î4÷î6”î=î>E îF½î ìï —î aîïî�îåî#î1îÆîfî!(rî"gï —î#1ï —î%qî'™ï —î(Iï —î)[rî*™ï —î+dï —qî-¼ï —î.Ãï —î0†î2kî5Dî<9î?îCmî ìïïî ‘î Æîõ îuîà î!Ìî#pî%@î'3î*<î.4î/Úî2&î ìïqî Éî0îî—îdîAîîî!‹î#+î$[î'©î*ïî.î0Wî3¼î7sî9tî<î>• îDçîF†î ìïÊî ®îEîÚ î®îSîŸ î ìïLîÒî" î½î!îËî%î(î+î-wî0Wî2rî4¾ïLî5‰ïLî7|qî:nïLî;ïLîD.îG#î ìï¤î Äî|î©îtîÕ î!ûî#�î%þî(Öî*Žî+× î3 î4Œî7²î<œî?»îBhîH#î ìïýî² î˜îi î!Pî#çî(Zî+@ î1zî3( î9õî<ÎîAWîCiîGCî ìïVîÅwî ìï/ qî ìï Üî ƒî/ îüî«î î&.î)Uî.î4Ùî7f î>rîB`îGêî ìï 5îcî¶xî›ï 5vî)Èïöÿ áTVm$ÇObjectnotationClientsofthispackagemayuseobjectnotationtocallanyprocedurewhosefirstparameteris"t:Table".Forinstance,write"table.Insert[node,key]"insteadof"OrderedSymbolTable.Insert[table,node,key]".ChangeLogCreatedbyMBrownonMBrownon11-Apr-8117:00:29ByeditingOrderedSymbolTable.ChangedbyMBrownonJune28,198211:31amCEDARinterface;addedDeleteAllItems.ChangedbyMBrownonNovember17,198210:44amCompareProcnowtakesnamedparameters.DuplicateKeyisanERROR,raisedwithmonitorunlocked.3wî ìïaíî?qî ìï^Ÿî‰î4îÔîîî}î!sî&Ðî(|î+î-¹î3ìî7ëî:ÂîA#îB–îD¼î ìï\÷î �îîwî Àî$jî)î*¤ð!î?‡îCxîFDï\÷pî ìïXîëxî ìïSßîîîÙîàî¥î «î'7qî ìïQdî î~xî ìïNéî¾î¹îî…î×îî"Zî&rî ìïLnqîUïLnî¹ïLnîYî:xî ìïIóî¾î¹îî…î Xî"•î%Ûî)šqî ìïGx îkîFîÑî% î$à î-Jî.¶î0©î6…î:qî=mîB~vî)ÈïÿÕTVm$Êÿ TIMESROMANþŸÿ TIMESROMANþYÿ HELVETICAþŸÿ TIMESROMANþŸÿLAURELþŸÿ TIMESROMANþæÿ TIMESROMANþæÿ TIMESROMANþŸÿ TIMESROMANþ * GJj/š“ôÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿOrderedSymbolTableRef.mesa17-Nov-82 10:56:52