getDiff method

void getDiff(
  1. List<int> additions,
  2. List<int> removals
)

getDiff

Implementation

void getDiff(List<int> additions, List<int> removals) {
  final a = current;
  final b = previous;
  final al = a.length;
  final bl = b.length;

  int j = 0;
  for (int i = 0; i < al; i++) {
    bool found = false;
    final keyA = a[i]!;
    while (b[j] != null && keyA > b[j]!) {
      j++;
    }
    found = keyA == b[j];

    if (!found) {
      _unpackAndPush(additions, keyA);
    }
  }
  j = 0;
  for (int i = 0; i < bl; i++) {
    bool found = false;
    final keyB = b[i]!;
    while (a[j] != null && keyB > a[j]!) {
      j++;
    }
    found = a[j] == keyB;

    if (!found) {
      _unpackAndPush(removals, keyB);
    }
  }
}