1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465(**************************************************************************)(* *)(* 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|[]->Nonelettops=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