public boolean getAndSet(int index) {
        assert index >= 0 && index < (wlen << 6);

        int wordNum = index >> 6; // div 64
        int bit = index & 0x3f; // mod 64
        long bitmask = 1L << bit;
        boolean val = (word(wordNum) & bitmask) != 0;
        setWord(wordNum, word(wordNum) | bitmask);
        return val;
    }
Sets a bit and returns the previous value. The index should be less than the BitSet
size.

@param index the index to set
@return previous state of the index
indexr-common/src/main/java/io/indexr/util/DirectBitMap.java