/** * Obtain a prioritised array where the indices 0 to n which correspond to * the provided {@code atoms}. * * @param focus focus of the tetrahedral atom * @param atoms the atom * @param n number of atoms * @return prioritised indices */ private int[] priority(int focus, IAtom[] atoms, int n) { int[] rank = new int[n]; for (int i = 0; i < n; i++) rank[i] = i; for (int j = 1; j < n; j++) { int v = rank[j]; int i = j - 1; while ((i >= 0) && hasPriority(focus, atomToIndex.get(atoms[v]), atomToIndex.get(atoms[rank[i]]))) { rank[i + 1] = rank[i--]; } rank[i + 1] = v; } return rank; }
/** * Obtain a prioritised array where the indices 0 to n which correspond to * the provided {@code atoms}. * * @param focus focus of the tetrahedral atom * @param atoms the atom * @param n number of atoms * @return prioritised indices */ private int[] priority(int focus, IAtom[] atoms, int n) { int[] rank = new int[n]; for (int i = 0; i < n; i++) rank[i] = i; for (int j = 1; j < n; j++) { int v = rank[j]; int i = j - 1; while ((i >= 0) && hasPriority(focus, atomToIndex.get(atoms[v]), atomToIndex.get(atoms[rank[i]]))) { rank[i + 1] = rank[i--]; } rank[i + 1] = v; } return rank; }