All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.vertexium.util.ArrayUtils Maven / Gradle / Ivy

There is a newer version: 4.10.0
Show newest version
package org.vertexium.util;

public class ArrayUtils {
    /**
     * Determines if all values in a1 appear in a2 and that all values in a2 appear in a2.
     */
    public static  boolean intersectsAll(T[] a1, T[] a2) {
        for (T anA1 : a1) {
            if (!contains(a2, anA1)) {
                return false;
            }
        }

        for (T anA2 : a2) {
            if (!contains(a1, anA2)) {
                return false;
            }
        }

        return true;
    }

    public static  boolean contains(T[] a1, T v) {
        for (T anA1 : a1) {
            if (anA1.equals(v)) {
                return true;
            }
        }
        return false;
    }

    public static boolean startsWith(byte[] array, byte[] seq) {
        if (array.length < seq.length) {
            return false;
        }
        for (int i = 0; i < seq.length; i++) {
            if (array[i] != seq[i]) {
                return false;
            }
        }
        return true;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy