class ISINGrid {

    public int getRowIndex(int binIndex) {
        final int[] binOffsets = this.binOffsets;
        final int totalBinCount = this.totalBinCount;

        int iL = 0;
        int iU = rowCount - 1;
        int iM;

        if (binIndex < 0 || binIndex >= totalBinCount) {
            return -1;
        }

        do {
// todo - check if this is an optimization or not
//            if (binIndex == binOffsets[iL]) {
//                return iL;
//            }
//            if (binIndex == binOffsets[iU]) {
//                return iU;
//            }
            iM = (iL + iU - 1) / 2;
            if (binIndex < binOffsets[iM]) {
                iU = iM;
            } else if (binIndex >= binOffsets[iM + 1]) {
                iL = iM + 1;
            } else {
                return iM;
            }
        } while (iL != iU);

        return iL;
    }

    public  ISINGrid(int rowCount);

}