but as-is, you're still doing a linear scan.  The comparator should be comparing the offsets anyway, which would then make this code trivial and wouldn't need any scan at all.