12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970(**************************************************************************)(* *)(* OCaml *)(* *)(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)(* *)(* Copyright 1996 Institut National de Recherche en Informatique et *)(* en Automatique. *)(* *)(* All rights reserved. This file is distributed under the terms of *)(* the GNU Lesser General Public License version 2.1, with the *)(* special exception on linking described in the file LICENSE. *)(* *)(**************************************************************************)type'at={mutablec:'alist;mutablelen:int;}exceptionEmptyletcreate()={c=[];len=0;}letclears=s.c<-[];s.len<-0letcopys={c=s.c;len=s.len;}letpushxs=s.c<-x::s.c;s.len<-s.len+1letpops=matchs.cwith|hd::tl->s.c<-tl;s.len<-s.len-1;hd|[]->raiseEmptyletpop_opts=matchs.cwith|hd::tl->s.c<-tl;s.len<-s.len-1;Somehd|[]->Noneletdrops=matchs.cwith|_hd::tl->s.c<-tl;s.len<-s.len-1|[]->raiseEmptylettops=matchs.cwith|hd::_->hd|[]->raiseEmptylettop_opts=matchs.cwith|hd::_->Somehd|[]->Noneletis_emptys=(s.c=[])letlengths=s.lenletiterfs=List.iterfs.cletfoldfaccs=List.fold_leftfaccs.c(** {1 Iterators} *)letto_seqs=List.to_seqs.cletadd_seqqi=Seq.iter(funx->pushxq)iletof_seqg=lets=create()inadd_seqsg;s