/*
 * @(#)SegmentNode.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.util.ArrayList;

/**
 */
public class SegmentNode<T extends Segment> {

    private int start = 0;
    private int end = 0;
    private SegmentNode leftSon = null;
    private SegmentNode rightSon = null;
    private ArrayList<T> data = null;

    /**
     * Constructor of the node- gets begining and end of interval
     * @param start
     * @param end
     */
    public SegmentNode(int start, int end) {
        this.start = start;
        this.end = end;
        data = new ArrayList<T>();
    }

    public int getStart() {
        return this.start;

    }

    public int getEnd() {
        return this.end;
    }

    public SegmentNode leftSon() {

        return this.leftSon;
    }

    public SegmentNode rightSon() {
        return this.rightSon;
    }

    public void insertData(T seg) {
        data.add(seg);
    }

    public void removeData(T seg) {
        data.remove(seg);
    }

    public ArrayList getData() {
        return this.data;
    }

    public void setLeftSon(SegmentNode leftSon) {
        this.leftSon = (SegmentNode) leftSon;
    }

    public void setRightSon(SegmentNode rightSon) {
        this.rightSon = (SegmentNode) rightSon;
    }

    public int getNumEdges() {
        return this.data.size();
    }
}
