void update(Uuid topicId, int partitionId, int[] prevElr, int[] nextElr) {
        int[] prev;
        if (prevElr == null) {
            prev = NONE;
        } else {
            prev = Replicas.clone(prevElr);
            Arrays.sort(prev);
        }
        int[] next;
        if (nextElr == null) {
            next = NONE;
        } else {
            next = Replicas.clone(nextElr);
            Arrays.sort(next);
        }

        int i = 0, j = 0;
        while (true) {
            if (i == prev.length) {
                if (j == next.length) {
                    break;
                }
                int newReplica = next[j];
                add(newReplica, topicId, partitionId);
                j++;
            } else if (j == next.length) {
                int prevReplica = prev[i];
                remove(prevReplica, topicId, partitionId);
                i++;
            } else {
                int prevReplica = prev[i];
                int newReplica = next[j];
                if (prevReplica < newReplica) {
                    remove(prevReplica, topicId, partitionId);
                    i++;
                } else if (prevReplica > newReplica) {
                    add(newReplica, topicId, partitionId);
                    j++;
                } else {
                    i++;
                    j++;
                }
            }
        }
    }
Update our records of a partition's ELR.

@param topicId       The topic ID of the partition.
@param partitionId   The partition ID of the partition.
@param prevElr       The previous ELR, or null if the partition is new.
@param nextElr       The new ELR, or null if the partition is being removed.
metadata/src/main/java/org/apache/kafka/controller/BrokersToElrs.java