<INTERFACE> The <CD/Queue/ structure <SEEALSO> <STRREF TOPID/Fifo/ </SEEALSO> <PP> The <STRREF NOLINK/Queue/ structure provides a simple implementation of mutable queues. The current implementation relies on the applicative queues defined in <STRREF NOLINK/Fifo/, and therefore has similar performance. <SPEC> <TYPE><TYPARAM>'a<ID>queue <SPEC> <EXN>Dequeue <SPEC> <VAL>mkQueue<TY>unit -> 'a queue <COMMENT> <PROTOTY> mkQueue <ARG/()/ </PROTOTY> returns an empty queue. <SPEC> <VAL>clear<TY>'a queue -> unit <COMMENT> <PROTOTY> clear <ARG/qu/ </PROTOTY> removes all the elements in <ARG/qu/. <SPEC> <VAL>isEmpty<TY>'a queue -> bool <COMMENT> <PROTOTY> isEmpty <ARG/qu/ </PROTOTY> returns true if <ARG/qu/ is empty. <SPEC> <VAL>enqueue<TY>('a queue * 'a) -> unit <COMMENT> <PROTOTY> enqueue (<ARG/qu/, <ARG/a/) </PROTOTY> appends <ARG/a/ to the end of <ARG/qu/. <SPEC> <VAL>dequeue<TY>'a queue -> 'a <RAISES> <PROTOTY> dequeue <ARG/qu/ </PROTOTY> removes and returns the head element in <ARG/qu/. Raises the exception <VAL>delete<TY>('a queue * ('a -> bool)) -> unit <COMMENT> <PROTOTY> delete (<ARG/qu/, <ARG/f/) </PROTOTY> deletes all elements in <ARG/qu/ satisfying the predicate <ARG/f/. <SPEC> <VAL>head<TY>'a queue -> 'a <RAISES> <PROTOTY> head <ARG/qu/ </PROTOTY> returns the head of <ARG/qu/ without removing it. Raises the exception <VAL>peek<TY>'a queue -> 'a option <COMMENT> <PROTOTY> peek <ARG/qu/ </PROTOTY> returns the head of <ARG/qu/ if it exists; otherwise, returns <VAL>length<TY>'a queue -> int <COMMENT> <PROTOTY> length <ARG/qu/ </PROTOTY> returns the number of elements in <ARG/qu/. At present, this is a linear time operation. <SPEC> <VAL>contents<TY>'a queue -> 'a list <COMMENT> <PROTOTY> contents <ARG/qu/ </PROTOTY> returns the elements in <ARG/qu/ in queue order. This is a linear time operation. <SPEC> <VAL>app<TY>('a -> unit) -> 'a queue -> unit <COMMENT> <PROTOTY> app <ARG/f/ <ARG/qu/ </PROTOTY> applies the function <ARG/f/ to the elements in <ARG/qu/ in queue order. This is equivalent to: `List.app f (contents qu)` <SPEC> <VAL>map<TY>('a -> 'b) -> 'a queue -> 'b queue <COMMENT> <PROTOTY> map <ARG/f/ <ARG/qu/ </PROTOTY> creates a new queue by mapping the elements in <ARG/qu/ by <ARG/f/. This is equivalent to: `let val newq = mkQueue () in app (fn v => enqueue(newq,f v)) qu; newq end` <SPEC> <VAL>foldl<TY>(('a * 'b) -> 'b) -> 'b -> 'a queue -> 'b <COMMENT> <PROTOTY> foldl <ARG/f/ <ARG/a/ <ARG/qu/ </PROTOTY> folds the elements of the queue from the head to the tail. This is equivalent to: `List.foldl f a (contents qu))` <SPEC> <VAL>foldr<TY>(('a * 'b) -> 'b) -> 'b -> 'a queue -> 'b <COMMENT> <PROTOTY> foldr <ARG/f/ <ARG/a/ <ARG/qu/ </PROTOTY> folds the elements of the queue from the tail to the head. This is equivalent to: `List.foldr f a (contents qu))` </INTERFACE>