1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768(*
* MultiMap - Polymorphic maps with multiple associations
* Copyright (C) 1996-2003 Xavier Leroy, Nicolas Cannasse, Markus Mottl
* Copyright (C) 2008 David Teller, LIFO, Universite d'Orleans
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version,
* with the special exception on linking described in file LICENSE.
*
* This library 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. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*)type('a,'b)t=('a,'bBatSet.t)BatMap.tletempty=BatMap.emptyletis_empty =BatMap.is_emptyletfindkt=tryBatMap.findktwithNot_found->BatSet.emptyletaddkdt=BatMap.modify_defBatSet.emptyk(BatSet.add d)tletremove_allkt=BatMap.removektletremovekdt=tryletset=BatSet.removed(BatMap.findkt)inifBatSet.is_emptysetthenBatMap.removektelseBatMap.addksett;withNot_found->tletmem=BatMap.mem(* let exists = mem *)letiter=BatMap.iterletmap=BatMap.mapletmapi=BatMap.mapiletfold=BatMap.foldletfoldi=BatMap.foldiletmodify=BatMap.modifyletmodify_def=BatMap.modify_defletmodify_opt=BatMap.modify_optlet(|>)xf=fxletenumt=BatMap.enumt|>BatEnum.map(fun(k,s)->BatSet.enum s|>BatEnum.map(funx->(k,x)))|>BatEnum.concatletof_enume=BatEnum.fold(funacc(k,d)->addkdacc)emptyeletprint?(first="{\n")?(last="\n}")?(sep=",\n")?(kvsep=": ")print_kprint_voutt=letprint_one out(k,v)=BatPrintf.fprintfout"%a%s%a"print_kkkvsepprint_vvinBatEnum.print~first~last~sepprint_oneout(enumt)moduleInfix=structlet(-->)mapkey=findkeymaplet(<--)map(key,value)=addkey value mapend