set method

void set(
  1. int i,
  2. int j
)

set

Implementation

void set(int i,int j){
  // Insertion sort. This way the diff will have linear complexity.
  final key = getKey(i, j);
  final current = this.current;
  int index = 0;
  while (current[index] != null && key > current[index]!) {
    index++;
  }
  if (key == current[index]) {
    return; // Pair was already added
  }
  for (int j = current.length - 1; j >= index; j--) {
    current[j + 1] = current[j]!;
  }
  current[index] = key;
}