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

org.nd4j.linalg.primitives.Pair Maven / Gradle / Ivy

There is a newer version: 1.0.0-M2.1
Show newest version
package org.nd4j.linalg.primitives;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.Arrays;

/**
 * Simple pair implementation
 *
 * @author [email protected]
 */
@AllArgsConstructor
@Data
@NoArgsConstructor
@Builder
public class Pair implements Serializable {
    private static final long serialVersionUID = 119L;

    protected K key;
    protected V value;

    @Override
    public String toString() {
        return "Pair{" +
                "key=" + (key instanceof int[] ? Arrays.toString((int[]) key) : key) +
                ", value=" + (value instanceof int[] ? Arrays.toString((int[]) value) : value) +
                '}';
    }

    public K getLeft() {
        return key;
    }

    public V getRight() {
        return value;
    }

    public K getFirst() {
        return key;
    }

    public V getSecond() {
        return value;
    }

    public void setFirst(K first) {
        key = first;
    }

    public void setSecond(V second) {
        value = second;
    }

    public static  Pair of(T key, E value) {
        return new Pair(key, value);
    }

    public static  Pair makePair(T key, E value) {
        return new Pair(key, value);
    }

    public static  Pair create(T key, E value) {
        return new Pair(key, value);
    }

    public static  Pair pairOf(T key, E value) {
        return new Pair(key, value);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy