package CipherCracker;

import java.util.Arrays;

public class IntSequence {
    private final int[] data;
    private final int cachedHashCode;

    // Copies the data into an Array and computes the hash
    public IntSequence(int[] data) {
        this.data = Arrays.copyOf(data, data.length);
        this.cachedHashCode = Arrays.hashCode(this.data);
    }

    // Returns the precomputed hash
    @Override
    public int hashCode() {
        return this.cachedHashCode;
    }

    // Checks if two values are equal to each other
    @Override
    public boolean equals(Object obj) {
        if (this == obj) return true;
        if (!(obj instanceof IntSequence other)) return false;
        return Arrays.equals(this.data, other.data);
    }
}