@Test public void testUtilUnsignedIntersection() { char[] data1 = fromShorts(new short[]{-19, -17, -15, -13, -11, -9, -7, -5, -3, -1}); char[] data2 = fromShorts(new short[]{-18, -16, -14, -12, -10, -8, -1}); assertTrue(Util.unsignedIntersects(data1, data1.length, data2, data2.length)); char[] data3 = fromShorts(new short[]{-19, -17, -15, -13, -11, -9, -7}); char[] data4 = fromShorts(new short[]{-18, -16, -14, -12, -10, -8, -6, -4, -2, 0}); assertFalse(Util.unsignedIntersects(data3, data3.length, data4, data4.length)); char[] data5 = {}; char[] data6 = {}; assertFalse(Util.unsignedIntersects(data5, data5.length, data6, data6.length)); }
public static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2) { if ((0 == length1) || (0 == length2)) { return false; } int k1 = 0; int k2 = 0; char s1 = set1[k1]; char s2 = set2[k2]; mainwhile: while (true) { if (s2 < s1) { do { ++k2; if (k2 == length2) { break mainwhile; } s2 = set2[k2]; } while (s2 < s1); } if (s1 < s2) { do { ++k1; if (k1 == length1) { break mainwhile; } s1 = set1[k1]; } while (s1 < s2); } else { return true; } } return false; }
Util { public static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2) { if ((0 == length1) || (0 == length2)) { return false; } int k1 = 0; int k2 = 0; char s1 = set1[k1]; char s2 = set2[k2]; mainwhile: while (true) { if (s2 < s1) { do { ++k2; if (k2 == length2) { break mainwhile; } s2 = set2[k2]; } while (s2 < s1); } if (s1 < s2) { do { ++k1; if (k1 == length1) { break mainwhile; } s1 = set1[k1]; } while (s1 < s2); } else { return true; } } return false; } }
Util { public static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2) { if ((0 == length1) || (0 == length2)) { return false; } int k1 = 0; int k2 = 0; char s1 = set1[k1]; char s2 = set2[k2]; mainwhile: while (true) { if (s2 < s1) { do { ++k2; if (k2 == length2) { break mainwhile; } s2 = set2[k2]; } while (s2 < s1); } if (s1 < s2) { do { ++k1; if (k1 == length1) { break mainwhile; } s1 = set1[k1]; } while (s1 < s2); } else { return true; } } return false; } private  Util(); }
Util { public static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2) { if ((0 == length1) || (0 == length2)) { return false; } int k1 = 0; int k2 = 0; char s1 = set1[k1]; char s2 = set2[k2]; mainwhile: while (true) { if (s2 < s1) { do { ++k2; if (k2 == length2) { break mainwhile; } s2 = set2[k2]; } while (s2 < s1); } if (s1 < s2) { do { ++k1; if (k1 == length1) { break mainwhile; } s1 = set1[k1]; } while (s1 < s2); } else { return true; } } return false; } private  Util(); static Container[] addOffset(Container source, char offsets); static int advanceUntil(char[] array, int pos, int length, char min); static int iterateUntil(char[] array, int pos, int length, int min); static void fillArrayAND(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void fillArrayANDNOT(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void fillArrayXOR(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void flipBitmapRange(long[] bitmap, int start, int end); @Deprecated static int cardinalityInBitmapWordRange(long[] bitmap, int start, int end); static int cardinalityInBitmapRange(long[] bitmap, int start, int end); static int maxLowBitAsInteger(); static void resetBitmapRange(long[] bitmap, int start, int end); static int intersectArrayIntoBitmap(long[] bitmap, char[] array, int length); static int select(long w, int j); static void setBitmapRange(long[] bitmap, int start, int end); @Deprecated static int setBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); @Deprecated static int flipBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); @Deprecated static int resetBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); static int unsignedBinarySearch(final char[] array, final int begin, final int end,
      final char k); static int unsignedDifference(final char[] set1, final int length1, final char[] set2,
      final int length2, final char[] buffer); static int unsignedDifference(CharIterator set1, CharIterator set2,
                                       final char[] buffer); static int unsignedExclusiveUnion2by2(final char[] set1, final int length1,
      final char[] set2, final int length2, final char[] buffer); static int unsignedIntersect2by2(final char[] set1, final int length1, final char[] set2,
      final int length2, final char[] buffer); static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2); static int unsignedLocalIntersect2by2Cardinality(final char[] set1, final int length1,
      final char[] set2, final int length2); static int unsignedUnion2by2(
          final char[] set1, final int offset1, final int length1,
          final char[] set2, final int offset2, final int length2,
          final char[] buffer); static long toUnsignedLong(int x); static void partialRadixSort(int[] data); }
Util { public static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2) { if ((0 == length1) || (0 == length2)) { return false; } int k1 = 0; int k2 = 0; char s1 = set1[k1]; char s2 = set2[k2]; mainwhile: while (true) { if (s2 < s1) { do { ++k2; if (k2 == length2) { break mainwhile; } s2 = set2[k2]; } while (s2 < s1); } if (s1 < s2) { do { ++k1; if (k1 == length1) { break mainwhile; } s1 = set1[k1]; } while (s1 < s2); } else { return true; } } return false; } private  Util(); static Container[] addOffset(Container source, char offsets); static int advanceUntil(char[] array, int pos, int length, char min); static int iterateUntil(char[] array, int pos, int length, int min); static void fillArrayAND(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void fillArrayANDNOT(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void fillArrayXOR(final char[] container, final long[] bitmap1,
      final long[] bitmap2); static void flipBitmapRange(long[] bitmap, int start, int end); @Deprecated static int cardinalityInBitmapWordRange(long[] bitmap, int start, int end); static int cardinalityInBitmapRange(long[] bitmap, int start, int end); static int maxLowBitAsInteger(); static void resetBitmapRange(long[] bitmap, int start, int end); static int intersectArrayIntoBitmap(long[] bitmap, char[] array, int length); static int select(long w, int j); static void setBitmapRange(long[] bitmap, int start, int end); @Deprecated static int setBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); @Deprecated static int flipBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); @Deprecated static int resetBitmapRangeAndCardinalityChange(long[] bitmap, int start, int end); static int unsignedBinarySearch(final char[] array, final int begin, final int end,
      final char k); static int unsignedDifference(final char[] set1, final int length1, final char[] set2,
      final int length2, final char[] buffer); static int unsignedDifference(CharIterator set1, CharIterator set2,
                                       final char[] buffer); static int unsignedExclusiveUnion2by2(final char[] set1, final int length1,
      final char[] set2, final int length2, final char[] buffer); static int unsignedIntersect2by2(final char[] set1, final int length1, final char[] set2,
      final int length2, final char[] buffer); static boolean unsignedIntersects(char[] set1, int length1, char[] set2, int length2); static int unsignedLocalIntersect2by2Cardinality(final char[] set1, final int length1,
      final char[] set2, final int length2); static int unsignedUnion2by2(
          final char[] set1, final int offset1, final int length1,
          final char[] set2, final int offset2, final int length2,
          final char[] buffer); static long toUnsignedLong(int x); static void partialRadixSort(int[] data); static final boolean USE_HYBRID_BINSEARCH; }