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

org.jgrasstools.gears.utils.CheckPoint Maven / Gradle / Ivy

The newest version!
/*
 * This file is part of JGrasstools (http://www.jgrasstools.org)
 * (C) HydroloGIS - www.hydrologis.com 
 * 
 * JGrasstools is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see .
 */
package org.jgrasstools.gears.utils;

/**
 * A point that can checked by comparison.
 * 
 * @author Andrea Antonello (www.hydrologis.com)
 */
public class CheckPoint implements Comparable {
    public int col;
    public int row;
    public int index;

    public CheckPoint( int col, int row, int index ) {
        this.col = col;
        this.row = row;
        this.index = index;
    }

    public int compareTo( CheckPoint o ) {
        /*
         * if row and col are equal, return 0, which will 
         * anyways trigger and exception
         */
        if (col == o.col && row == o.row) {
            return 0;
        }

        /*
         * in the case of non equal row/col, we need to make the normal sort
         */
        if (index < o.index) {
            return -1;
        } else if (index > o.index) {
            return 1;
        } else {
            return 0;
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy