'Returns the index of the given job, or if it\'s not found, the index where the job should be inserted based on
the given timestamp.
:type timestamp: int
:type job_id: str'

def _get_job_index(self, timestamp, job_id):

    (lo, hi) = (0, len(self._jobs))
    timestamp = (float('inf') if (timestamp is None) else timestamp)
    while (lo < hi):
        mid = ((lo + hi) // 2)
        (mid_job, mid_timestamp) = self._jobs[mid]
        mid_timestamp = (float('inf') if (mid_timestamp is None) else mid_timestamp)
        if (mid_timestamp > timestamp):
            hi = mid
        elif (mid_timestamp < timestamp):
            lo = (mid + 1)
        elif (mid_job.id > job_id):
            hi = mid
        elif (mid_job.id < job_id):
            lo = (mid + 1)
        else:
            return mid
    return lo
