getMaxIntPos method
Finds the positive-valued maximum value of the numbers in array
,
assuming that array
] contains values >= 0.
array
may contain null values, they are skipped.
Returns the maximum, its index
.
If 2 maxima with the same value exist, the 1st one is returned.
Implementation
static List<int> getMaxIntPos(List<int> array) {
int max_value = -1;
int max_index = -1;
if (array != null) {
for (int i = 0; i < array.length; i += 1) {
if (array[i] != null && array[i] > max_value) {
max_value = array[i];
max_index = i;
}
}
}
return [max_value, max_index];
}