protected static float[] mergeUniqueElements(float[] arrayA, float[] arrayB) {
    if (arrayA.length == 0) {
      return arrayB;
    } else if (arrayB.length == 0) {
      return arrayA;
    }

    int aIndex = 0;
    int bIndex = 0;
    int numDuplicates = 0;
    // This will be the merged list but may be longer than what is needed if there are duplicates.
    // If there are, the 0 elements at the end need to be truncated.
    float[] mergedNotTruncated = new float[arrayA.length + arrayB.length];
    for (int i = 0; i < mergedNotTruncated.length; i++) {
      final float a = aIndex < arrayA.length ? arrayA[aIndex] : Float.NaN;
      final float b = bIndex < arrayB.length ? arrayB[bIndex] : Float.NaN;

      if (Float.isNaN(b) || a < b) {
        mergedNotTruncated[i] = a;
        aIndex++;
      } else if (Float.isNaN(a) || b < a) {
        mergedNotTruncated[i] = b;
        bIndex++;
      } else {
        mergedNotTruncated[i] = a;
        aIndex++;
        bIndex++;
        numDuplicates++;
      }
    }

    if (numDuplicates == 0) {
      return mergedNotTruncated;
    }

    return Arrays.copyOf(mergedNotTruncated, mergedNotTruncated.length - numDuplicates);
  }
Takes two sorted float arrays and merges their elements while removing duplicates.
lottie/src/main/java/com/airbnb/lottie/parser/GradientColorParser.java