static _updateMeasureMask_swapGate(gate, state, row) {
        if (gate !== Gates.Special.SwapHalf) {
            return;
        }

        if (state.earlierRowWithSwapGate === undefined) {
            state.earlierRowWithSwapGate = row;
            return;
        }

        // Swap gate swaps measurement states.
        let other = 1 << state.earlierRowWithSwapGate;
        let d = row - state.earlierRowWithSwapGate;
        let bit = 1 << row;
        state.measureMask = (state.measureMask & ~(other | bit)) |
            ((state.measureMask & other) << d) |
            ((state.measureMask & bit) >> d);
        state.earlierRowWithSwapGate = undefined;
    }
@param {!Gate} gate
@param {{measureMask: !int, earlierRowWithSwapGate: undefined|!int}} state
@param row
@returns {void}
@private