/***********************************
  (C) Copyright 1992-1993; dit/upm
   Distributed under the conditions stated in the
   TOPO General Public License (see file LICENSE)
 ***********************************
 $Log: sets.c,v $
 * Revision 1.1  1993/01/21  20:25:19  lotos
 * Initial revision
 *
 ***********************************/

#ifndef lint
static char rcsid[]= "$Id: sets.c,v 1.1 1993/01/21 20:25:19 lotos Exp $";
#endif

# include "sets.h"

PRIVATE TNODE*
addeltset (elt, set)
  TNODE* elt;
  TNODE* set;
{
  TNODE* nd;

  nd= new_node (elt->type);
  nd->value0= elt->value0;
  nd->value1= elt->value1;
  nd->brothers= set;
  nd->sons= elt->sons;
  return nd;
}

PRIVATE TNODE*
addtwosets (set1, set2)
  TNODE* set1;
  TNODE* set2;
{
  if (set1 == NULL)
    return set2;
  return addeltset (set1, addtwosets (set1->brothers, set2));
}

PUBLIC TNODE*
setunion (sets)
  TNODE* sets;
{
  if (sets->brothers == NULL)
    return (TNODE*) fdclr (c_set, sets, -15);
  return addtwosets ((TNODE*) fdclr (c_set, sets, -15),
		     setunion (sets->brothers));
}

