12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182(************************************************************************)(* * The Rocq Prover / The Rocq Development Team *)(* v * Copyright INRIA, CNRS and contributors *)(* <O___,, * (see version control and CREDITS file for authors & dates) *)(* \VV/ **************************************************************)(* // * This file is distributed under the terms of the *)(* * GNU Lesser General Public License Version 2.1 *)(* * (see LICENSE file for the text of the license) *)(************************************************************************)type'at='aoptionarrayoptionrefletreturna:'at=ref(Somea)letif_valid(r:'at)=match!rwith|Somea->a|None->invalid_arg"Tried to reuse invalidated NoDupArray."(** Non-destructive get operator *)let(let+)rf=f(if_validr)letdestruct_getr=let+a=rinr:=None;a(** Destructive get operator *)let(let-)rf=f(destruct_getr)letupdaterf:'bt=let-a=rinreturn(fa)(** Updating functor operator *)let(let*)=updateletmaken=return(Array.makenNone)letgetia=let+a=aina.(i)letis_filledia=let+a=ainOption.has_somea.(i)letaddiea=let*a=ainbeginmatcha.(i)with|None->a.(i)<-Somee|Some_->invalid_arg"Tried to add duplicate in NoDupArray."end;aletfill_remainingea=let*a=ainArray.iteri(funielt->beginmatcheltwith|None->a.(i)<-Somee|Some_->()end)a;aletto_arraya=let-a=ainArray.map(functionSomee->e|None->invalid_arg"Tried to cast non-full NoDupArray.")aletto_array_opta=let-a=ainletexceptionStopintrySome(Array.map(functionSomee->e|None->raiseStop)a)withStop->NonemoduleInternal=structletunsafe_to_array=if_validend