123456789101112131415161718192021222324252627282930313233343536373839404142(**************************************************************************)(* *)(* OCamlFormat *)(* *)(* Copyright (c) Facebook, Inc. and its affiliates. *)(* *)(* This source code is licensed under the MIT license found in *)(* the LICENSE file in the root directory of this source tree. *)(* *)(**************************************************************************)type('key,'value,'cmp)t=('key,'valuelist,'cmp)Map.tmoduleM(K:sigtypettypecomparator_witnessend)=structtypenonrec'vt=(K.t,'v,K.comparator_witness)tendletupdate_multimap~src~dst~f=Option.fold(Map.findmapsrc)~init:(Map.removemapsrc)~f:(funnew_mapsrc_data->Map.updatenew_mapdst~f:(fundst_data->Option.folddst_data~init:src_data~f))letchange_multimapkeydata=Map.changemapkey~f:(function_->Somedata)letpartition_multimap~src~dst~f=letmove,dontmove=List.partition_tf(Map.find_multimapsrc)~finletmap=List.fold_left~init:map(List.revmove)~f:(funmapdata->Map.add_multimap~key:dst~data)inchange_multimapsrcdontmoveletfiltermap~f=Map.mapmap~f:(List.filter~f)letto_listmap=Map.to_alistmap|>List.concat_map~f:snd