public void flip(long startIndex, long endIndex) {
        assert startIndex >= 0;
        assert endIndex <= (wlen << 6);

        if (endIndex <= startIndex) return;
        int startWord = (int) (startIndex >> 6);

        // since endIndex is one past the end, this is index of the last
        // word to be changed.
        int endWord = expandingWordNum(endIndex - 1);

        long startmask = -1L << startIndex;
        long endmask = -1L >>> -endIndex; // 64-(endIndex&0x3f) is the same as -endIndex
        // due to wrap

        if (startWord == endWord) {
            setWord(startWord, word(startWord) ^ (startmask & endmask));
            return;
        }

        setWord(startWord, word(startWord) ^ startmask);

        for (int i = startWord + 1; i < endWord; i++) {
            setWord(i, ~word(i));
        }

        setWord(endWord, word(endWord) ^ endmask);
    }
Flips a range of bits. [startIndex, endIndex)

@param startIndex lower index
@param endIndex   one-past the last bit to flip
indexr-common/src/main/java/io/indexr/util/DirectBitMap.java