/* -*- Mode: C -*-
 *
 * $Header: /home/gene/library/website/docsrc/cloop/src/RCS/timeevent.cxx,v 395.1 2008/04/20 17:25:50 gene Exp $
 *
 * Copyright (c) 2006 Gene Michael Stover.  All rights reserved.
 *
 * This program 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 2 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, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

#include "this.h"

/*
 */
C_API int
TIMEEVENT_Cmp (const TimeEvent *a, const TimeEvent *b)
{
  int cmp;

  assert (a != NULL);
  assert (b != NULL);
  if (a->when < b->when) cmp = -1;
  else if (a->when == b->when) {
    if (a->n < b->n) cmp = -1;
    else if (a->n == b->n) {
      fprintf (stderr, "\n%s:%d: warning: A's N == B's N.", __FILE__,
               __LINE__);
      cmp = 0;
    } else {
      cmp = 1;
    }
  } else {
    assert ((a->when > b->when) || (a->when == b->when && a->n > b->n));
    cmp = 1;
  }
  return cmp;
}

/*
 */
Boolean
TIMEEVENT_IsLess::operator() (TimeEvent const &a, TimeEvent const &b) {
  return TIMEEVENT_Cmp (&a, &b) < 0;
}

/* --- end of file --- */
