private void removeRemovedCallbacks(int startIndex, long removed) {
        // The naive approach should be fine. There may be a better bit-twiddling approach.
        final int endIndex = startIndex + Long.SIZE;

        long bitMask = 1L << (Long.SIZE - 1);
        for (int i = endIndex - 1; i >= startIndex; i--) {
            if ((removed & bitMask) != 0) {
                mCallbacks.remove(i);
            }
            bitMask >>>= 1;
        }
    }
Removes callbacks from startIndex to startIndex + Long.SIZE, based
on the bits set in removed.

@param startIndex The index into the mCallbacks to start removing callbacks.
@param removed    The bits indicating removal, where each bit is set for one callback
                  to be removed.
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/util/obs/CallbackRegistry.java