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

com.github.dieterdepaepe.jsearch.problem.npuzzle.PuzzleIndex Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package com.github.dieterdepaepe.jsearch.problem.npuzzle;

/**
 * A 2 dimensional index of a specific field in a {@link com.github.dieterdepaepe.jsearch.problem.npuzzle.SlidingPuzzle}.
 * @author Dieter De Paepe
 */
public class PuzzleIndex {
    public final int row;
    public final int column;

    public PuzzleIndex(int row, int column) {
        this.row = row;
        this.column = column;
    }

    @Override
    public String toString() {
        return "(" + row + ", " + column + ")";
    }

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

        PuzzleIndex that = (PuzzleIndex) o;

        if (column != that.column) return false;
        if (row != that.row) return false;

        return true;
    }

    @Override
    public int hashCode() {
        int result = row;
        result = 31 * result + column;
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy