/** * Ensures that the n-th element is in a correct position in the list based on * the distance from origin. * @param left start of range * @param right end of range (exclusive) * @param n element to put in the right position * @param origin origin to compute the distance to */ private void nthElement(int left, int right, int n, double[] origin) { int npos = partitionItems(left, right, n, origin); if (npos < n) nthElement(npos + 1, right, n, origin); if (npos > n) nthElement(left, npos, n, origin); }
/** * Ensures that the n-th element is in a correct position in the list based on * the distance from origin. * @param left start of range * @param right end of range (exclusive) * @param n element to put in the right position * @param origin origin to compute the distance to */ private void nthElement(int left, int right, int n, double[] origin) { int npos = partitionItems(left, right, n, origin); if (npos < n) nthElement(npos + 1, right, n, origin); if (npos > n) nthElement(left, npos, n, origin); }