7.7.2 Object Style

We also turn queues into an abstract data structure Queue.ozfModule/.

A precompiled version of Queue.ozf is available on-line at Functors/Version.3.2/Queue.ozf

<Queue.oz>=
functor 
import 
   Queue(new fromList size get put top  
         isEmpty clear toList enq deq  ) at 'QueueLib.ozf' 
export 
   new      : NewQueueObject  
   fromList : ListToQueueObject
define 
   fun {NewQueueObject}      {ToObject {Queue.new}} end 
   fun {ListToQueueObject L} {ToObject {Queue.fromList L}} end 
   fun {ToObject Q}
      fun  {Size   } {Queue.size    Q  } end 
      fun  {Get    } {Queue.get     Q  } end 
      proc {Put   X} {Queue.put     Q X} end 
      fun  {Top    } {Queue.top     Q  } end 
      fun  {IsEmpty} {Queue.isEmpty Q  } end 
      proc {Clear  } {Queue.clear   Q  } end 
      fun  {ToList } {Queue.toList  Q  } end 
      proc {Enq   X} {Queue.enq     Q X} end 
      fun  {Deq    } {Queue.deq     Q  } end 
   in 
      unit(
         type    : queue
         size    : Size
         get     : Get
         put     : Put
         top     : Top
         isEmpty : IsEmpty
         clear   : Clear
         toList  : ToList
         enq     : Enq
         deq     : Deq)
   end 
end


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