export function getOrCreateMap < X , Y , Z > ( map , key ) { if ( map . has ( key ) ) return map . get ( key ) ; else { const yToP = new Map < Y , Z > ( ) ; map . set ( key , yToP ) ; return yToP ; } } export function getOrCreateSet < X , Y > ( map , key ) { if ( map . has ( key ) ) return map . get ( key ) ; else { const yToP = new Set < Y > ( ) ; map . set ( key , yToP ) ; return yToP ; } }