Java Utililty Methods Array Intersect

List of utility methods to do Array Intersect

Description

The list of methods to do Array Intersect are organized into topic(s).

Method

doublearrayInterp(double[] inputArray, double index)
array Interp
int cap = inputArray.length - 1;
if (index <= 0) {
    return inputArray[0];
} else if (index >= cap) {
    return inputArray[cap];
} else {
    int first = (int) Math.floor(index);
    double offset = index - first;
...
booleanarraysIntersect(Object[] array1, Object[] array2)
Check if two arrays have at least one common element.
boolean intersect = false;
for (int i = 0; i < array1.length && !intersect; ++i) {
    Object e1 = array1[i];
    if (e1 != null) {
        for (int j = 0; j < array2.length && !intersect; ++j) {
            Object e2 = array2[j];
            intersect = e1.equals(e2);
return intersect;
byte[]byteIntersection(byte[] a, byte[] b)
byte Intersection
int max = Math.max(a.length, b.length);
byte[] newarray = new byte[max];
Arrays.fill(newarray, (byte) 0);
for (int i = 0; i < max; i++) {
    byte aval = 0;
    byte bval = 0;
    if (i >= a.length) {
        aval = 0;
...
int[]getArrayIntersection(int a[], int b[])
get Array Intersection
return Arrays.stream(a).flatMap(i -> Arrays.stream(b).filter(j -> i == j)).distinct().toArray();
ListgetNonIntersection(int[] interval, int[] intervalToRemove)
Returns interval(s) of non-intersection area for interval1
List<int[]> outList = new ArrayList<int[]>();
int[] intersection = getIntersection(interval, intervalToRemove);
if (intersection[0] == interval[0]) {
    if (intersection[1] == interval[1]) {
    } else {
        outList.add(new int[] { intersection[1] + 1, interval[1] });
    return outList;
...
booleanhasIntersection(String a1[], String a2[], int mode)
has Intersection
if (a1 == null || a2 == null)
    return false;
if (a1 == a2)
    return a1.length > 0;
java.util.List<String> v = new ArrayList<String>();
createIntersection(a1, a2, mode, v, false);
return v.size() > 0;
intintersect(boolean[] mask, int[] examples, boolean[] intersection)
A generic intersect function that
if (intersection.length != mask.length)
    throw new RuntimeException("Argument and return value have different length.");
Arrays.fill(intersection, false);
int count = 0;
for (int i = 0; i < examples.length; i++)
    if (mask[examples[i]]) {
        intersection[examples[i]] = true;
        count++;
...
int[]intersect(int[] sorted1, int[] sorted2)
intersect
int[] result = new int[Math.min(sorted1.length, sorted2.length)];
int i = 0, j = 0, k = 0;
while (i < sorted1.length && j < sorted2.length) {
    if (sorted1[i] < sorted2[j])
        i++;
    else if (sorted1[i] > sorted2[j])
        j++;
    else {
...
int[]intersect(int[]... arrays)
Returns the intersection vector of a series of input arrays.
if (arrays.length == 0)
    return new int[0];
Set<Integer> intersectionSet = new LinkedHashSet<Integer>();
intersectionSet.addAll(toList(arrays[0]));
for (int i = 1; i < arrays.length; i++)
    intersectionSet.retainAll(toList(arrays[i]));
return toArray(intersectionSet);
String[]intersect(String[] arr1, String[] arr2)
intersect
Map<String, Boolean> map = new HashMap<String, Boolean>();
LinkedList<String> list = new LinkedList<String>();
for (String str : arr1) {
    if (!map.containsKey(str)) {
        map.put(str, Boolean.FALSE);
for (String str : arr2) {
...