123456789101112131415161718192021222324252627282930313233343536373839404142(**************************************************************************)(* *)(* Ocamlgraph: a generic graph library for OCaml *)(* Copyright (C) 2004-2010 *)(* Sylvain Conchon, Jean-Christophe Filliatre and Julien Signoles *)(* *)(* This software is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Library General Public *)(* License version 2.1, with the special exception on linking *)(* described in file LICENSE. *)(* *)(* This software is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *)(* *)(**************************************************************************)(** Purely applicative queues implemented in a standard way
using a pair of lists (Hood & Melville 1981) *)type'at='alist*'alist(** a queue is a pair (prefix, xiffus), with elements popped from prefix
and inserted into xiffus
invariant: prefix=[] -> xiffus=[] *)letempty=[],[]letis_empty(prefix,_)=prefix=[]letaddqueueelt=matchqueuewith|[],[]->[elt],[]|prefix,xiffus->prefix,elt::xiffuslethead=function|head::_,_->head|[],_->raiseNot_foundlettail=function|[_],xiffus->List.revxiffus,[]|_::prefix,xiffus->prefix,xiffus|[],_->raiseNot_found