7.5.2 Object Style

<Dictionary.oz>=
functor 
export 
   new:NewDict
define 
   D = Dictionary
   fun{NewDict}
      Dict = {D.new}
      proc{Put Key Val}
         Dict.Key := Val
      end 
      fun{Get Key}
         Dict.Key
      end 
      fun{Member Key}
         {D.member Dict Key}
      end 
      fun{Keys}
         {D.keys Dict}
      end 
      fun{ToRecord}
         {D.toRecord unit Dict}
      end 
      fun{ToRecordLabel Label}
         {D.toRecord Label Dict}
      end 
      fun{CondGet Key Default}
         {CondSelect Dict Key Default}
      end 
      proc{Remove Key}
         {D.remove Dict Key}
      end 
      proc{RemoveAll}
         {D.removeAll Dict}
      end 
      fun{Entries}
         {D.entries Dict}
      end 
      fun{Items}
         {D.items Dict}
      end 
      fun{IsEmpty}
         {D.isEmpty Dict}
      end 
      proc{Collect Key Val}
         {Put Key Val|{CondGet Key nil}}
      end 
   in 
      unit(put      :Put
           get      :Get
           condGet  :CondGet
           toRecord :ToRecord
           isEmpty  :IsEmpty
           entries  :Entries
           items    :Items
           dict     :Dict
           toKeys   :Keys
                toRecordLabel:ToRecordLabel
           condSelect:CondGet
           member   :Member
           keys     :Keys
           remove   :Remove
           removeAll:RemoveAll
           collect  :Collect)
   end 
end


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)