I am looking for a better way to check if an array of primitives contains all the primitives in another array in Java. For instance:
int[] a = new int[]{1,2};
int[] b = new int[]{1,2,3,4,5};
int[] c = new int[]{2,4,6};
containsAll(b, a);
containsAll(a, b);
containsAll(c, b);
Where containsAll is a function that checks to see if there is a second parameter inside the first parameter !!! I do not want to convert int arrays to Integer arrays in order to use the following method:
Arrays.asList(a).containsAll(Arrays.asList(b))
Because I think that if the arrays are huge, it will be a big waste of performance !!! But maybe I'm wrong, and the best solution is that ... Do you have an idea?
source
share