/** Compile a mapping */
static <T> int[] compileMapping(List<T> domain, List<T>range)
{
if ( domain.size() != range.size() )
throw new AtlasException("Bad mapping: lengths not the same: "+domain+" -> "+range) ;
int[] cols = new int[domain.size()] ;
boolean[] mapped = new boolean[domain.size()] ;
//Arrays.fill(mapped, false) ;
for ( int i = 0 ; i < domain.size() ; i++ )
{
T input = domain.get(i) ;
int j = range.indexOf(input) ;
if ( j < 0 )
throw new AtlasException("Bad mapping: missing mapping: "+domain+" -> "+range) ;
if ( mapped[j] )
throw new AtlasException("Bad mapping: duplicate: "+domain+" -> "+range) ;
cols[i] = j ;
mapped[j] = true ;
}
return cols ;
}