/*
 * @(#)Segment.java  1.0  2010-12-25
 *
 * Copyright (c) 2000-2010 Werner Randelshofer, Immensee, Switzerland.
 * All rights reserved.
 *
 * You may not use, copy or modify this file, except in compliance with the
 * license agreement you entered into with Werner Randelshofer.
 * For details see accompanying license terms.
 */
package ch.randelshofer.segmenttree;

import java.awt.Point;

public class Segment implements Comparable {

    private int start;
    private int end;

    public Segment(int start, int end) {
        this.start = start;
        this.end = end;

    }

    public int getStart() {
        return start;
    }

    public int getEnd() {
        return end;
    }

    /**
     * Comparator in order to sort the edges,(X,Y)
     */
    public int compareTo(Object o) {
        Segment that = (Segment) o;
        if (this.start < that.start) {
            return -1;
        } else if (this.start > that.start) {
            return 1;
        }

        return 0;
    }

    @Override
    public int hashCode() {
        return start + (end << 16);
    }

    @Override
    public boolean equals(Object o) {
        Segment that = (Segment) o;
        return that.start == this.start && that.end == this.end;
    }
}
