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

com.bestvike.tuple.Tuple Maven / Gradle / Ivy

The newest version!
package com.bestvike.tuple;

/**
 * Created by 许崇雷 on 2017-07-23.
 */
public final class Tuple {
    private Tuple() {
    }

    public static  Tuple1 create(T1 item1) {
        return new Tuple1<>(item1);
    }

    public static  Tuple2 create(T1 item1, T2 item2) {
        return new Tuple2<>(item1, item2);
    }

    public static  Tuple3 create(T1 item1, T2 item2, T3 item3) {
        return new Tuple3<>(item1, item2, item3);
    }

    public static  Tuple4 create(T1 item1, T2 item2, T3 item3, T4 item4) {
        return new Tuple4<>(item1, item2, item3, item4);
    }

    public static  Tuple5 create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5) {
        return new Tuple5<>(item1, item2, item3, item4, item5);
    }

    public static  Tuple6 create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6) {
        return new Tuple6<>(item1, item2, item3, item4, item5, item6);
    }

    public static  Tuple7 create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7) {
        return new Tuple7<>(item1, item2, item3, item4, item5, item6, item7);
    }

    public static  TupleN> create(T1 item1, T2 item2, T3 item3, T4 item4, T5 item5, T6 item6, T7 item7, T8 item8) {
        return new TupleN<>(item1, item2, item3, item4, item5, item6, item7, new Tuple1<>(item8));
    }

    static int combineHashCodes(int h1, int h2) {
        return (h1 << 5) + h1 ^ h2;
    }

    static int combineHashCodes(int h1, int h2, int h3) {
        return Tuple.combineHashCodes(Tuple.combineHashCodes(h1, h2), h3);
    }

    static int combineHashCodes(int h1, int h2, int h3, int h4) {
        return Tuple.combineHashCodes(Tuple.combineHashCodes(h1, h2), Tuple.combineHashCodes(h3, h4));
    }

    static int combineHashCodes(int h1, int h2, int h3, int h4, int h5) {
        return Tuple.combineHashCodes(Tuple.combineHashCodes(h1, h2, h3, h4), h5);
    }

    static int combineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6) {
        return Tuple.combineHashCodes(Tuple.combineHashCodes(h1, h2, h3, h4), Tuple.combineHashCodes(h5, h6));
    }

    static int combineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7) {
        return Tuple.combineHashCodes(Tuple.combineHashCodes(h1, h2, h3, h4), Tuple.combineHashCodes(h5, h6, h7));
    }

    static int combineHashCodes(int h1, int h2, int h3, int h4, int h5, int h6, int h7, int h8) {
        return Tuple.combineHashCodes(Tuple.combineHashCodes(h1, h2, h3, h4), Tuple.combineHashCodes(h5, h6, h7, h8));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy