private static int effectiveIndex(Array array, Procedure proc, Object[] args, int[] work) throws Throwable { Object mapval = proc.applyN(args); if (mapval instanceof Values) { Values mapvals = (Values) mapval; for (int i = 0, j = 0; (i = mapvals.nextPos(i)) != 0; j++) { work[j] = ((Number) mapvals.getPosPrevious(i)).intValue(); } } else work[0] = ((Number) mapval).intValue(); if (array instanceof GeneralArray) return ((GeneralArray) array).resolve(work); else return work[0]; }