Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] View of /sml/trunk/src/smlnj-lib/Util/queue.sml
ViewVC logotype

View of /sml/trunk/src/smlnj-lib/Util/queue.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (download) (annotate)
Thu Jun 1 18:34:03 2000 UTC (19 years, 5 months ago) by monnier
File size: 904 byte(s)
bring revisions from the vendor branch to the trunk
(* queue.sml
 *
 * COPYRIGHT (c) 1993 by AT&T Bell Laboratories.  See COPYRIGHT file for details.
 *
 * Imperative fifos
 *
 *)

structure Queue :> QUEUE =
  struct
    type 'a queue = 'a Fifo.fifo ref

    exception Dequeue = Fifo.Dequeue

    fun mkQueue () = ref Fifo.empty

    fun clear q = (q := Fifo.empty)

    fun enqueue (q,x) = q := (Fifo.enqueue (!q, x))

    fun dequeue q = let 
          val (newq, x) = Fifo.dequeue (!q) 
          in
            q := newq;
            x
          end
  
    fun delete (q, pred) = (q := Fifo.delete (!q, pred))
    fun head q = Fifo.head (!q)
    fun peek q = Fifo.peek (!q)
    fun isEmpty q = Fifo.isEmpty (!q)
    fun length q = Fifo.length (!q)
    fun contents q = Fifo.contents (!q)
    fun app f q = Fifo.app f (!q)
    fun map f q = ref(Fifo.map f (!q))
    fun foldl f b q = Fifo.foldl f b (!q)
    fun foldr f b q = Fifo.foldr f b (!q)

  end

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0