private int[] FindExtremes(Vector vector, Vector bounds) { int[] result = new int[2]; int i = 0; while (vector[i] < bounds[0]) i++; result[0] = i; i = vector.Length - 1; while (vector[i] > bounds[1]) i--; result[1] = i; return result; }