code: public static int unsignedIntersect2by2(final short[] set1, final int length1, final short[] set2,
        final int length2, final short[] buffer) {
      final int THRESHOLD = 25;
      if (set1.length * THRESHOLD < set2.length) {
        return unsignedOneSidedGallopingIntersect2by2(set1, length1, set2, length2, buffer);
      } else if (set2.length * THRESHOLD < set1.length) {
        return unsignedOneSidedGallopingIntersect2by2(set2, length2, set1, length1, buffer);
      } else {
        return unsignedLocalIntersect2by2(set1, length1, set2, length2, buffer);
      }
    }
docs: Intersect two sorted lists and write the result to the provided output array
  
  @param set1 first array
  @param length1 length of first array
  @param set2 second array
  @param length2 length of second array
  @param buffer output array
  @return cardinality of the intersection