dominion-dev/dominion-ecs-java

I have another question about IndexKey

endison1986 opened this issue · 0 comments

@enricostara hi friend, I have another question about IndexKey
I read the source code of IndexKey,why the constructor IndexKey(int value) donot initialize the data field.
Will it cause it to obtain or overwrite the value of other IndexKey when it is used as the Key of the Map?

public final class IndexKey {
    private final int hashCode;
    private final byte[] data;

    public IndexKey(int value) {
        this.hashCode = value;
        data = null;
    }

    public IndexKey(int[] array) {...}

    public IndexKey(boolean[] checkArray, int min, int max, int length) {...}

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        return Arrays.equals(((IndexKey) o).data, data);
    }

    @Override
    public int hashCode() {
        return hashCode;
    }

    @Override
    public String toString() {...}
}