src/main/java/chlx/hashing/similarity/JaccardIndex.java
public static double indexWithMinThreshold(double minSimThreshold, @NotNull long[] s1,
			@NotNull long[] s2) {
		if (s1.length == 0) {
			if (s2.length == 0) {
				return 1;
			}
			return 0;
		} else if (s2.length == 0) {
			return 0;
		}

		int maxDif1 = (int) (s1.length * (1 - minSimThreshold));
		int maxDif2 = (int) (s2.length * (1 - minSimThreshold));

		if (s1[maxDif1] > s2[s2.length - 1] || s2[maxDif2] > s1[s1.length - 1]) {
			return 0;
		}

		if (s1.length < MIN_SIM_THRESHOLD_MIN_WORTHY_LENGTH
				|| s2.length < MIN_SIM_THRESHOLD_MIN_WORTHY_LENGTH) {
			double sim = index(s1, s2);
			return sim < minSimThreshold ? 0 : sim;
		}

		int count = 0;

		int i1 = 0;
		int i2 = 0;
		int dif1 = 0;
		int dif2 = 0;
		while (i1 < s1.length && i2 < s2.length) {
			if (s1[i1] < s2[i2]) {
				++i1;
				++dif1;
				if (dif1 > maxDif1) {
					return 0;
				}
			} else if (s2[i2] < s1[i1]) {
				++i2;
				++dif2;
				if (dif2 > maxDif2) {
					return 0;
				}
			} else {
				++count;
				++i1;
				++i2;
			}
		}

		return (double) count / (s1.length + s2.length - count);
	}
/**
	 * @implSpec Calculate similarity between 2 sorted long arrays with unique element if similarity
	 * < minSimThreshold then return 0; this has been optimized for {@link
	 * chlx.hashing.lsh.LSHComputer}
	 */
@implSpec Calculate similarity between 2 sorted long arrays with unique element if similarity
< minSimThreshold then return 0; this has been optimized for {@link
chlx.hashing.lsh.LSHComputer}
@implSpec Calculate similarity between 2 sorted long arrays with unique element if similarity < minSimThreshold then return 0 ; this has been optimized for { @link chlx . hashing . lsh . LSHComputer }
public static double indexWithMinThreshold(double minSimThreshold, @NotNull long[] s1,
			@NotNull long[] s2) {
		if (s1.length == 0) {
			if (s2.length == 0) {
				return 1;
			}
			return 0;
		} else if (s2.length == 0) {
			return 0;
		}
		int maxDif1 = (int) (s1.length * (1 - minSimThreshold));
		int maxDif2 = (int) (s2.length * (1 - minSimThreshold));
		if (s1[maxDif1] > s2[s2.length - 1] || s2[maxDif2] > s1[s1.length - 1]) {
			return 0;
		}
		if (s1.length < MIN_SIM_THRESHOLD_MIN_WORTHY_LENGTH
				|| s2.length < MIN_SIM_THRESHOLD_MIN_WORTHY_LENGTH) {
			double sim = index(s1, s2);
			return sim < minSimThreshold ? 0 : sim;
		}
		int count = 0;
		int i1 = 0;
		int i2 = 0;
		int dif1 = 0;
		int dif2 = 0;
		while (i1 < s1.length && i2 < s2.length) {
			if (s1[i1] < s2[i2]) {
				++i1;
				++dif1;
				if (dif1 > maxDif1) {
					return 0;
				}
			} else if (s2[i2] < s1[i1]) {
				++i2;
				++dif2;
				if (dif2 > maxDif2) {
					return 0;
				}
			} else {
				++count;
				++i1;
				++i2;
			}
		}
		return (double) count / (s1.length + s2.length - count);
	}
public static double indexWithMinThreshold ( double minSimThreshold , @ NotNull long [ ] s1 , @ NotNull long [ ] s2 ) { if ( s1 . length == 0 ) { if ( s2 . length == 0 ) { return 1 ; } return 0 ; } else if ( s2 . length == 0 ) { return 0 ; } int maxDif1 = ( int ) ( s1 . length * ( 1 - minSimThreshold ) ) ; int maxDif2 = ( int ) ( s2 . length * ( 1 - minSimThreshold ) ) ; if ( s1 [ maxDif1 ] > s2 [ s2 . length - 1 ] || s2 [ maxDif2 ] > s1 [ s1 . length - 1 ] ) { return 0 ; } if ( s1 . length < MIN_SIM_THRESHOLD_MIN_WORTHY_LENGTH || s2 . length < MIN_SIM_THRESHOLD_MIN_WORTHY_LENGTH ) { double sim = index ( s1 , s2 ) ; return sim < minSimThreshold ? 0 : sim ; } int count = 0 ; int i1 = 0 ; int i2 = 0 ; int dif1 = 0 ; int dif2 = 0 ; while ( i1 < s1 . length && i2 < s2 . length ) { if ( s1 [ i1 ] < s2 [ i2 ] ) { ++ i1 ; ++ dif1 ; if ( dif1 > maxDif1 ) { return 0 ; } } else if ( s2 [ i2 ] < s1 [ i1 ] ) { ++ i2 ; ++ dif2 ; if ( dif2 > maxDif2 ) { return 0 ; } } else { ++ count ; ++ i1 ; ++ i2 ; } } return ( double ) count / ( s1 . length + s2 . length - count ) ; }
@implSpec Calculate similarity between 2 sorted long arrays with unique element if similarity
 < minSimThreshold then return 0; this has been optimized for {@link
 chlx.hashing.lsh.LSHComputer}
@implSpec Calculate similarity between 2 sorted long arrays with unique element if similarity < minSimThreshold then return 0 ; this has been optimized for { @link chlx . hashing . lsh . LSHComputer }