public static @Nullable long[] removeLong(@Nullable long[] cur, long val) {
    if (cur == null) {
      return null;
    }
    final int N = cur.length;
    for (int i = 0; i < N; i++) {
      if (cur[i] == val) {
        long[] ret = new long[N - 1];
        if (i > 0) {
          System.arraycopy(cur, 0, ret, 0, i);
        }
        if (i < (N - 1)) {
          System.arraycopy(cur, i + 1, ret, i, N - i - 1);
        }
        return ret;
      }
    }
    return cur;
  }
Removes value from given array if present, providing set-like behavior.
android/android_framework/base/src/main/java/github/tornaco/android/thanos/core/util/ArrayUtils.java