public int find(long searchKey) {
        int lowBound = 0;
        int upperBound = nElems - 1;
        int curIn;

        while (true) {
            curIn = (lowBound + upperBound) / 2;
            if (a[curIn] == searchKey)
                return curIn;
            else if (lowBound > upperBound)
                return -1;
            else {
                if (a[curIn] > searchKey)
                    upperBound = curIn - 1;
                else
                    lowBound = curIn + 1;
            }
        }
    }