int FindByDueTime (long nr)
{
int min = 0;
int max = list.Count - 1;
if (max < 0)
return -1;
if (max < 20) {
while (min <= max) {
Timer t = (Timer) list.GetByIndex (min);
if (t.next_run == nr)
return min;
if (t.next_run > nr)
return -1;
min++;
}
return -1;
}
while (min <= max) {
int half = min + ((max - min) >> 1);
Timer t = (Timer) list.GetByIndex (half);
if (nr == t.next_run)
return half;
if (nr > t.next_run)
min = half + 1;
else
max = half - 1;
}
return -1;
}