// (c) MIT 2003.  All rights reserved.

// -*-Mode: JDE-*- 
// $Id: CausalChain.java,v 1.3 2003/03/06 00:40:49 moltmans Exp $
// CausalChain.java -- 
// Author: Michael Oltmans <moltmans@ai.mit.edu> 
// Created: <Wed Jun 14 12:56:07 2000> 
// Time-stamp: <2000-07-12 16:33:16 moltmans> 
package rec.annotate;

import java.util.*;
import rec.annotate.rules.*;

public class CausalChain implements Interval
{
  private LinkedList m_events;
  private long m_startTime;
  private long m_endTime;

  public CausalChain() {
    m_events = new LinkedList();
    m_startTime = Long.MAX_VALUE;
    m_endTime = Long.MIN_VALUE;
  }

  public LinkedList getEvents()
  {
    return m_events;
  }

  public long getStartTime()
  {
    return m_startTime;
  }
  public long getEndTime() 
  {
    return m_endTime;
  }

  public boolean contains( CanonicalEvent event ) 
  {
    return m_events.contains( event );
  }
  

  public void add( CanonicalEvent event ) 
  {
    // if this is a new element check if it is earlier on or latter
    m_events.addLast( event );
    if( event.getStartTime() < m_startTime ) {
      m_startTime = event.getStartTime();
    }
    if( event.getEndTime() > m_endTime ) {
      m_endTime = event.getEndTime();
    }
  }
}
