head	1.23;
access;
symbols
	bobbase:1.22
	bob:1.22.1
	r2_1:1.15
	r2_0:1.15
	r1_1_beta:1.14
	r1_1_alpha:1.13
	r1_0:1.13
	r0_11:1.13
	r0_10:1.12
	r0_9:1.12
	Eglin_alpha_1:1.11;
locks; strict;
comment	@ * @;


1.23
date	95.01.20.03.56.51;	author gmt;	state Exp;
branches;
next	1.22;

1.22
date	94.10.06.18.41.05;	author gmt;	state Exp;
branches
	1.22.1.1;
next	1.21;

1.21
date	94.10.06.18.37.05;	author gmt;	state Exp;
branches;
next	1.20;

1.20
date	94.10.04.21.00.18;	author gmt;	state Exp;
branches;
next	1.19;

1.19
date	94.10.04.05.59.09;	author gmt;	state Exp;
branches;
next	1.18;

1.18
date	94.10.03.17.54.28;	author thoth;	state Exp;
branches;
next	1.17;

1.17
date	94.09.27.04.41.19;	author gmt;	state Exp;
branches;
next	1.16;

1.16
date	94.09.20.17.28.38;	author thoth;	state Exp;
branches;
next	1.15;

1.15
date	94.08.22.15.10.18;	author thoth;	state Exp;
branches;
next	1.14;

1.14
date	94.08.09.18.41.41;	author thoth;	state Exp;
branches;
next	1.13;

1.13
date	94.03.14.15.34.56;	author thoth;	state Exp;
branches;
next	1.12;

1.12
date	93.11.17.17.57.17;	author thoth;	state Exp;
branches;
next	1.11;

1.11
date	93.06.10.17.08.50;	author thoth;	state Exp;
branches;
next	1.10;

1.10
date	93.05.26.16.32.04;	author thoth;	state Exp;
branches;
next	1.9;

1.9
date	93.05.26.13.49.20;	author thoth;	state Exp;
branches;
next	1.8;

1.8
date	93.02.20.15.25.02;	author thoth;	state Exp;
branches;
next	1.7;

1.7
date	93.02.08.19.56.57;	author thoth;	state Exp;
branches;
next	1.6;

1.6
date	92.12.14.16.18.50;	author jm;	state Exp;
branches;
next	1.5;

1.5
date	92.10.22.14.04.47;	author jm;	state Exp;
branches;
next	1.4;

1.4
date	92.09.29.15.27.24;	author jm;	state Exp;
branches;
next	1.3;

1.3
date	92.09.16.16.41.30;	author jm;	state Exp;
branches;
next	1.2;

1.2
date	92.09.16.14.47.23;	author jm;	state Exp;
branches;
next	1.1;

1.1
date	92.09.16.14.46.28;	author jm;	state Exp;
branches;
next	;

1.22.1.1
date	94.12.08.14.47.56;	author thoth;	state Exp;
branches;
next	;


desc
@ValueSet.C renamed ValueSet.c
@


1.23
log
@*** empty log message ***
@
text
@// Emacs -*- C++ -*-

//
//	Copyright 1993, Center for Computer Vision and Visualization,
//	University of Florida.  All rights reserved.
//

/*  $RCSfile: ValueSet.c,v $
    $Log: ValueSet.c,v $
 * Revision 1.22  1994/10/06  18:41:05  gmt
 * Fixed typo
 *
 * Revision 1.21  1994/10/06  18:37:05  gmt
 * temporary hack to make this compile with SC++ without proper bsearch
 * and qsort routines.
 *
 * Revision 1.20  1994/10/04  21:00:18  gmt
 * Changed ValueType to T since the ValueSet.c and ValueSet.h did not match.
 *
 * Revision 1.19  1994/10/04  05:59:09  gmt
 * Fixed SC++ problem with nested enums for IA::LatticeRelation
 *
 * Revision 1.18  1994/10/03  17:54:28  thoth
 * Added iterators.
 * changed ValueType to T.
 * removed the binary ops between Sets and scalars since they were
 * inaccessible to users and unused by the IA_Set class.
 *
 * Revision 1.17  1994/09/27  04:41:19  gmt
 * Changed IA::LatticeRelation to IA_LatticeRelation since the mac
 * doesn't deal with enums defined inside of templated classes.  Not
 * that IA_LatticeRelation is #defined to IA::LatticeRelation in
 * ia.h . . .
 *
 * Revision 1.16  1994/09/20  17:28:38  thoth
 * Handle some difficulties with G++ instantiation of static data members.
 *
 * Revision 1.15  1994/08/22  15:10:18  thoth
 * fix to operator<.  All this code needs a review.
 *
 * Revision 1.14  1994/08/09  18:41:41  thoth
 * Logic errors in < partly fixed.
 *
 * Revision 1.13  1994/03/14  15:34:56  thoth
 * Work around bug in CFront float formal parameters.
 * Need dummy for type().
 *
 * Revision 1.12  1993/11/17  17:57:17  thoth
 * use value_type_compare any place you need a comparison
 * of values.
 *
 * Revision 1.11  1993/06/10  17:08:50  thoth
 * Fix array constructor.
 *
 * Revision 1.10  93/05/26  16:32:04  thoth
 * Copyright Notices
 * 
 * Revision 1.9  93/05/26  13:49:20  thoth
 * move the special functions into another module
 * 
 * Revision 1.8  93/02/20  15:25:02  thoth
 * The LatticeRelation that was causing a compiler bug is now
 * used from IA instead of IA_ValueSet<T>.
 * 
 * Revision 1.7  93/02/08  19:56:57  thoth
 * added output method for testing.
 * Also added ifdefs since template implementation file are really
 * "headers".  We were having problems with multiple inclusion.
 * 
 * Revision 1.6  92/12/14  16:18:50  jm
 *  Renamed class ValueSet to IA_ValueSet
 * 
 * Revision 1.5  92/10/22  14:04:47  jm
 * fixed operator "<=" on two value sets
 * 
 * Revision 1.4  92/09/29  15:27:24  jm
 * *** empty log message ***
 * 
 * Revision 1.3  92/09/16  16:41:30  jm
 * added comments to remove_dup and count_dup functions.
 * changed NULL to 0.
 * 
 * Revision 1.2  92/09/16  14:47:23  jm
 * Included value_range function as an independent function
 * function contains() now returns 1 or 0
 * added keyword 'const' to function count_dup
 * added keyword 'const' to all member operators
 * added definition for operators '>' and '<'
 * added definition for function compare
 * 
 * Revision 1.1  92/09/16  14:46:28  jm
 * Initial revision
 * 
Revision 1.6  92/09/09  14:36:35  jm
cleaned up use of dynamic memory in operator.

Revision 1.5  92/09/08  14:37:44  jm
 the operators have been redefined to be class members in the case of
 valueset op element, and valueset op valueset. The combination
 element op valueset remains as a friend.
 the function make_set does not take parameters anymore. It operates on
 the internal value_array and size.
 function value_range has been changed from class member to independent. It
 will only work with integer arguments.
 predicate operators now return an int instead of a char, in order to be
 able to print the result.

Revision 1.4  92/09/01  13:59:36  jm
added friend functions for operators between elements and ValueSets.
Added a guard for the "bsearch" function
templatized ValueSet
changed the "-" operator to the "/" operator

Revision 1.3  92/08/28  10:01:36  jm
added RCS keywords "RCSfile" and "Log"

*/

#ifndef ValueSet_c_
#define ValueSet_c_

#include <iostream.h>
#include <stdlib.h>
#include "ValueSet.h"
#include "VSIter.h"

#ifndef IA_NO_AUTOINST_OF_STATIC_DATA
template <class T>
char IA_ValueSet<T>::dummy;
#endif

template <class T>
int IA_ValueSet<T>::contains(T e) const
{
    if (this->size == 0) return 0;
    T	e_ = e;
#ifdef __SC__
	return 0;
#else
    return ((int) bsearch((T *)(&e_), 
			 (T *)this->value_array,
			 this->size, sizeof(T),
			 this->value_type_compare) == 0 ? 0 : 1);
#endif
}
    
template <class T>
int IA_ValueSetComparator<T>::value_type_compare(
    const void *t1, const void *t2) {
    if (*(T *)t1 > *(T *)t2)
	return 1;
    
    if (*(T *)t1 < *(T *)t2)
	return -1;
    return 0;
}

template <class T>
IA_ValueSet<T>::IA_ValueSet(const IA_ValueSet<T>& vs) {
    this->size = vs.size;
    if (this->size == 0)
	this->value_array = 0;
    else {
	this->value_array = new T[this->size];
	for (unsigned int i = 0; i < this->size; i++)
	    this->value_array[i] = vs.value_array[i];
    }
}

template <class T>
IA_ValueSet<T>::IA_ValueSet(T v0) {
    this->value_array = new T[this->size = 1];
    
    this->value_array[0] = v0;
}

template <class T>
IA_ValueSet<T>::IA_ValueSet(T v0, T v1) {
    
    this->value_array = new T[this->size = 2];

    this->value_array[0] = v0;
    this->value_array[1] = v1;
    make_set();
}

template <class T>
IA_ValueSet<T>::IA_ValueSet(T v0, T v1, T v2) {

    this->value_array = new T[this->size = 3];
    
    this->value_array[0] = v0;
    this->value_array[1] = v1;
    this->value_array[2] = v2;
    make_set();
}

template <class T>
IA_ValueSet<T>::IA_ValueSet(T v0, T v1,T v2, 
			      T v3) {
    this->value_array = new T[this->size = 4];
    
    this->value_array[0] = v0;
    this->value_array[1] = v1;
    this->value_array[2] = v2;
    this->value_array[3] = v3;
    make_set();

}

template <class T>
IA_ValueSet<T>::IA_ValueSet(T v0, T v1, T v2, 
			      T v3, T v4) {
    this->value_array = new T[this->size = 5];
    
    this->value_array[0] = v0;
    this->value_array[1] = v1;
    this->value_array[2] = v2;
    this->value_array[3] = v3;
    this->value_array[4] = v4;
    make_set();
}

template <class T>
IA_ValueSet<T>::IA_ValueSet(const T* ar, unsigned int sz) {
    if (sz == 0) {
	this->size = 0;
	this->value_array = 0;
    }
    else {
	this->value_array = new T[this->size = sz];
	for (unsigned int i=0; i < sz; i++)
	    this->value_array[i] = ar[i];
	make_set();
    }
}

// make_set: sorts the value_array and removes duplicates.

template <class T>
void IA_ValueSet<T>::make_set() {
    if (this->size == 0)
	this->value_array = 0;
    else {
#ifndef __SC__
	qsort(this->value_array, this->size, sizeof(T),
	      this->value_type_compare);
#endif
	remove_dup();
    }
}

// remove_dup is for the private use of make_set
// this->size must not be 0.

template <class T>
void IA_ValueSet<T>::remove_dup() {
    
    T *clean_array = new T[this->size - count_dup()];
    
    unsigned int di = 0;
    
    for (unsigned int i=0; i < this->size - 1; i++)
	if (this->value_array[i] != this->value_array[i+1])
	    clean_array[di++] = this->value_array[i];
    clean_array[di++] = this->value_array[this->size - 1];
    delete [] this->value_array;
    this->value_array = clean_array;
    this->size = di;
}

// count_dup is for the private use of make_set

template <class T>
int IA_ValueSet<T>::count_dup() const {
    int count = 0;
    for (unsigned int i=0; i < this->size - 1; i++)
	if (this->value_array[i] == this->value_array[i+1])
	    count++;
    return count;
}

template <class T>
IA_ValueSet<T>& 
IA_ValueSet<T>::operator=  (const IA_ValueSet<T>& vs) {
    if (this == &vs) 
	return *this;

    // handle empty set possibility
    
    if (vs.size == 0) {
	delete[] this->value_array;  // OK even if value_array already 0
	this->value_array = 0; 
	this->size = 0;
	return *this;
    }
    
    // handle the typical case
    
    if (vs.size != this->size) {
	delete[] this->value_array;
	this->value_array = new T[vs.size];
	this->size = vs.size;
    }
    
    for (unsigned int i = 0; i < this->size; i++)
	this->value_array[i] = vs.value_array[i];
    
    return *this;
}


template <class T>
IA_BaseSetIter<T> *
IA_ValueSet<T> :: iterator() const
{
			// cast away const to allow frobbing of refcount
    return new IA_ValueSetIter<T>((IA_ValueSet<T>*)this);
}

//
//
//

template <class T>
IA_ValueSet<T> 
IA_ValueSet<T>::operator| (const IA_ValueSet<T> &right) const {
    unsigned int li = 0, ri = 0, ci = 0;

    if (this == &right) 
	return IA_ValueSet<T>(*this);

    T* temp = new T[this->size + right.size];
    while ((li < this->size) && (ri < right.size))
	if (value_type_compare(&this->value_array[li],&right.value_array[ri])<0)
	    temp[ci++] = this->value_array[li++];
	else {
	    temp[ci++] = right.value_array[ri];
	    if (this->value_array[li] == right.value_array[ri++])
		li++;
	}
    if (li == this->size)
	for (;ri < right.size;ri++)
	    temp[ci++] = right.value_array[ri];
    else
	for (;li < this->size;li++)
	    temp[ci++] = this->value_array[li];
    return IA_ValueSet<T>(temp, ci);
}

#if 0
template <class T>
IA_ValueSet<T> 
IA_ValueSet<T>::operator| (const T &right) const {
    return *this | IA_ValueSet<T>(right);
}

template <class T>
IA_ValueSet<T> 
operator| (const T &left, const IA_ValueSet<T> &right) {
    return IA_ValueSet<T>(left) | right;
}
#endif

//
//
//

template <class T>
IA_ValueSet<T> 
IA_ValueSet<T>::operator& (const IA_ValueSet<T> &right)  const {
    unsigned int li = 0, ri = 0, ci = 0;

    if ((this->empty()) || (right.empty()))
	return IA_ValueSet<T>();
    {
	T	lmax = this->max();
	T	lmin = this->min();
	T	rmax = right.max();
	T	rmin = right.min();
	if (value_type_compare(&lmax, &rmin)<0 ||
	    value_type_compare(&rmax, &lmin)<0)
	    return IA_ValueSet<T>();
    }
    if (this == &right) 
	return IA_ValueSet<T>(*this);

    T* temp = new T[this->card() < right.card() 
				    ? this->size : right.size];

    while ((li < this->size) && (ri < right.size))
	if (value_type_compare(&this->value_array[li],&right.value_array[ri])<0)
	    li++;
	else {
	    if (this->value_array[li] == right.value_array[ri]) {
		temp[ci++] = right.value_array[ri];
		li++;
	    }
	    ri++;
	}
    return IA_ValueSet<T>(temp, ci);
}

#if 0
template <class T>
IA_ValueSet<T> 
IA_ValueSet<T>::operator& (const T &right) const {
    if (this->contains(right))
	return IA_ValueSet<T>(right);
    else
	return IA_ValueSet<T>();
}

template <class T>
IA_ValueSet<T> 
operator& (const T &left, const IA_ValueSet<T> &right) {
    if (right.contains(left))
	return IA_ValueSet<T>(left);
    else
	return IA_ValueSet<T>();
}
#endif

//
//
//

template <class T>
IA_ValueSet<T> 
IA_ValueSet<T>::operator/ (const IA_ValueSet<T> &right) const {
    unsigned int li = 0, ri = 0, ci = 0;

    if (this->empty())
	return IA_ValueSet<T>();
    if (right.empty())
	return IA_ValueSet<T>(*this);
    if (this == &right) 
	return IA_ValueSet<T>();

    T* temp = new T[this->size];
    while ((li < this->size) && (ri < right.size)) {
	int cmp = value_type_compare(&this->value_array[li],
				     &right.value_array[ri]);
	if (cmp<0)
	    temp[ci++] = this->value_array[li++];
	else {
	    if (cmp==0)
		li++;
	    ri++;
	}
    }
    if (ri == right.size)
	for (;li<this->size;li++)
	    temp[ci++] = this->value_array[li];
    return IA_ValueSet<T>(temp, ci);
}

#if 0
template <class T>
IA_ValueSet<T> 
IA_ValueSet<T>::operator/ (const T &right) const {
    return *this / IA_ValueSet<T>(right);
}

template <class T>
IA_ValueSet<T> 
operator/ (const T &left, const IA_ValueSet<T> &right) {
    if (right.contains(left))
	return IA_ValueSet<T>();
    else
	return IA_ValueSet<T>(left);
}
#endif

//
//
//

template <class T>
IA_ValueSet<T> 
IA_ValueSet<T>::operator^ (const IA_ValueSet<T> &right) const {
    unsigned int li = 0, ri = 0, ci = 0;

    if (this->empty())
	return IA_ValueSet<T>(right);
    if (right.empty())
	return IA_ValueSet<T>(*this);
    if (this == &right) 
	return IA_ValueSet<T>();

    T* temp = new T[this->size + right.size];
    while ((li < this->size) && (ri < right.size)) {
	int cmp = value_type_compare(&this->value_array[li],
				     &right.value_array[ri]);
	if (cmp<0)
	    temp[ci++] = this->value_array[li++];
	else if (cmp>0)
	    temp[ci++] = right.value_array[ri++];
	else { 
	    li++;
	    ri++;
	}
    }
    if (ri == right.size)
	for (;li<this->size;li++)
	    temp[ci++] = this->value_array[li];
    if (li == this->size)
	for (;ri<right.size;ri++)
	    temp[ci++] = right.value_array[ri];
    return IA_ValueSet<T>(temp, ci);
}
#if 0
template <class T>
IA_ValueSet<T> 
IA_ValueSet<T>::operator^ (const T &right) const {

    if (this->contains(right))
	return IA_ValueSet<T>(*this / right);
    else
	return IA_ValueSet<T>(*this | right);
}

template <class T>
IA_ValueSet<T> 
operator^ (const T &left, const IA_ValueSet<T> &right) {

    if (right.contains(left))
	return IA_ValueSet<T>(right / left);
    else
	return IA_ValueSet<T>(right | left);
}
#endif

//
//
//

template <class T> 
int 
IA_ValueSet<T>::operator<= (const IA_ValueSet<T> &right) const {

    unsigned int li = 0, ri = 0;

    if (this->empty())
	return 1;
    if (right.empty())
	return 0;
    if (this == &right) return 1;
    while ((li < this->size) && (ri < right.size)) {
	int cmp = value_type_compare(&this->value_array[li],
				     &right.value_array[ri]);
	if (cmp<0)
	    return 0;
	else {
	    if (cmp==0)
		li++;
	    ri++;
	}
    }
    if (ri == right.size)
	if (li == this->size)
	    return 1;
	else
	    return 0;
    return 1;
}

#if 0
template <class T> 
int 
IA_ValueSet<T>::operator<= (const T &right) const {

    if (this->size == 0) 
	return 1;
    if (this->size == 1)
	return this->max() == right;
    return 0;
}

template <class T> 
int 
operator<= (const T &left, const IA_ValueSet<T> &right){

    if (right.contains(left)) 
	return 1;
    return 0;
}
#endif

//
//
//

template <class T>
int 
IA_ValueSet<T>::operator>= (const IA_ValueSet<T> &right) const {
    return right <= *this;
}

#if 0
template <class T>
int 
IA_ValueSet<T>::operator>= (const T &right) const {
    return right <= *this;
}

template <class T>
int 
operator>= (const T &left, const IA_ValueSet<T> &right){
    return right <= left;
}
#endif

//
//
//

template <class T> 
int 
IA_ValueSet<T>::operator< (const IA_ValueSet<T> &right) const {

    unsigned int li = 0, ri = 0;

    if (right.empty())
	return 0;
    if (this->empty())
	return 1;
    if (this->size >= right.size)
	return 0;		// short-circuits s<s

    while ((li < this->size) && (ri < right.size)) {
	int cmp = value_type_compare(&this->value_array[li],
				     &right.value_array[ri]);
	if (cmp<0)
	    return 0;
	else {
	    if (cmp==0)
		li++;
	    ri++;
	}
    }

    if (li == this->size)
	return 1;
    return 0;
}

#if 0
template <class T> 
int 
IA_ValueSet<T>::operator< (const T &) const {

    return (this->size == 0);
}

template <class T> 
int 
operator< (const T &left, const IA_ValueSet<T> &right){

    return (right.contains(left) && (right.size > 1));

}
#endif

//
//
//

template <class T>
int 
IA_ValueSet<T>::operator> (const IA_ValueSet<T> &right) const {

    return (right < *this);

}
#if 0
template <class T>
int 
IA_ValueSet<T>::operator> (const T &right) const {
    return (right < *this);
}

template <class T>
int 
operator> (const T &left, const IA_ValueSet<T> &right){
    return (right < left);
}
#endif

//
//
//

template <class T> 
int 
IA_ValueSet<T>::operator== (const IA_ValueSet<T> &right) const {

    if (this->size != right.size)
	return 0;
    for (unsigned int i = 0; i < this->size; i++)
       if (this->value_array[i] != right.value_array[i])
	   return 0;
    return 1;
}

#if 0
template <class T> 
int 
IA_ValueSet<T>::operator== (const T &right) const {

    if (this->size != 1)
	return 0;
    return this->max() == right;
}

template <class T> 
int 
operator== (const T &left, const IA_ValueSet<T> &right){

    if (right.size != 1)
	return 0;
    return right.max() == left;
}
#endif

//
//
//

template <class T> 
int 
IA_ValueSet<T>::operator!= (const IA_ValueSet<T> &right) const {
    return !(*this == right);
}

#if 0
template <class T> 
int 
IA_ValueSet<T>::operator!= (const T &right) const {
    return !(*this == right);
}

template <class T> 
int 
operator!= (const T &left, const IA_ValueSet<T> &right){
    return !(left == right);
}
#endif

//
//
//

template <class T>
#ifdef IA_NO_NESTED_ENUMS
IA_LatticeRelation
#else
IA::LatticeRelation
#endif
compare(const IA_ValueSet<T> &lhs, const IA_ValueSet<T> &rhs) {

   if (lhs == rhs)
       return IA::EQUAL;
   if (lhs < rhs)
       return IA::P_SUBSET;
   if (lhs > rhs)
       return IA::P_SUPERSET;
   return IA::NO_REL;

}

template <class T>
ostream& operator<< (ostream& st, const IA_ValueSet<T>& vs) {
    int last_index = vs.size-1;
    st << "<"; 
    if (vs.size > 0) {
	for (int i=0; i < last_index; i++)
	    st << vs.value_array[i] << " ";
	if (vs.size > 0)
	    st << vs.value_array[last_index];
    }
    st << ">" << '\n';
    return st;
}

#endif // ValueSet_c_
@


1.22
log
@Fixed typo
@
text
@d10 3
@


1.22.1.1
log
@Comparison rework to centralize computation.
@
text
@a9 3
 * Revision 1.22  1994/10/06  18:41:05  gmt
 * Fixed typo
 *
a534 2
#if 0				// Set.c will use the compare() function.

a746 2
#endif

d757 1
a757 10
compare(const IA_ValueSet<T> &lhs, const IA_ValueSet<T> &rhs)
{
#ifdef IA_NO_NESTED_ENUMS
    IA_LatticeRelation
#else
	IA::LatticeRelation
#endif
	    rval=IA::EQUAL;

    int	li,ri;			// left and right indices
d759 7
a765 1
    li = ri = 0;
a766 32
    while (li < lhs.size && ri < rhs.size) {
	int cmp = IA_ValueSet<T>::value_type_compare(&lhs.value_array[li],
						     &rhs.value_array[ri]);

	if (cmp<0) {
	    if (rval==IA::P_SUBSET) // Left was missing some from the right,
		return IA::NO_REL;  // now it has an extra.  No relation.
	    li++;
	    rval = IA::P_SUPERSET; // otherwise left is a superset so far
	} else if (cmp==0) {
	    li++;
	    ri++;
	} else /* cmp>0 */ {
	    if (rval==IA::P_SUPERSET) // Right was missing some from the left,
		return IA::NO_REL;    // now it has an extra.  No relation.
	    ri++;
	    rval = IA::P_SUBSET; // otherwise right is a superset so far
	}
    }
    if (li<lhs.size) {
	if (rval==IA::P_SUBSET)	// Left was missing some from the right,
	    return IA::NO_REL;  // now it has an extra.  No relation.
	return IA::P_SUPERSET; // otherwise left is a superset
    } else if (ri<rhs.size) {
	if (rval==IA::P_SUPERSET) // Right was missing some from the left,
	    return IA::NO_REL;  // now it has an extra.  No relation.
	return IA::P_SUBSET; // otherwise right is a superset
    } else {
	// ran out of items from both at the same time.  Whatever
	// we determined before is cool.
	return rval;
    }
@


1.21
log
@temporary hack to make this compile with SC++ without proper bsearch
and qsort routines.
@
text
@d10 4
d135 1
a135 1
	return 0
@


1.20
log
@Changed ValueType to T since the ValueSet.c and ValueSet.h did not match.
@
text
@d10 3
d130 3
d137 1
d238 1
d241 1
@


1.19
log
@Fixed SC++ problem with nested enums for IA::LatticeRelation
@
text
@d10 3
d122 2
a123 2
template <class ValueType>
int IA_ValueSet<ValueType>::contains(ValueType e) const
d126 4
a129 4
    ValueType	e_ = e;
    return ((int) bsearch((ValueType *)(&e_), 
			 (ValueType *)this->value_array,
			 this->size, sizeof(ValueType),
d133 2
a134 2
template <class ValueType>
int IA_ValueSetComparator<ValueType>::value_type_compare(
d136 1
a136 1
    if (*(ValueType *)t1 > *(ValueType *)t2)
d139 1
a139 1
    if (*(ValueType *)t1 < *(ValueType *)t2)
d144 2
a145 2
template <class ValueType>
IA_ValueSet<ValueType>::IA_ValueSet(const IA_ValueSet<ValueType>& vs) {
d150 1
a150 1
	this->value_array = new ValueType[this->size];
d156 3
a158 3
template <class ValueType>
IA_ValueSet<ValueType>::IA_ValueSet(ValueType v0) {
    this->value_array = new ValueType[this->size = 1];
d163 2
a164 2
template <class ValueType>
IA_ValueSet<ValueType>::IA_ValueSet(ValueType v0, ValueType v1) {
d166 1
a166 1
    this->value_array = new ValueType[this->size = 2];
d173 2
a174 2
template <class ValueType>
IA_ValueSet<ValueType>::IA_ValueSet(ValueType v0, ValueType v1, ValueType v2) {
d176 1
a176 1
    this->value_array = new ValueType[this->size = 3];
d184 4
a187 4
template <class ValueType>
IA_ValueSet<ValueType>::IA_ValueSet(ValueType v0, ValueType v1,ValueType v2, 
			      ValueType v3) {
    this->value_array = new ValueType[this->size = 4];
d197 4
a200 4
template <class ValueType>
IA_ValueSet<ValueType>::IA_ValueSet(ValueType v0, ValueType v1, ValueType v2, 
			      ValueType v3, ValueType v4) {
    this->value_array = new ValueType[this->size = 5];
d210 2
a211 2
template <class ValueType>
IA_ValueSet<ValueType>::IA_ValueSet(const ValueType* ar, unsigned int sz) {
d217 1
a217 1
	this->value_array = new ValueType[this->size = sz];
d226 2
a227 2
template <class ValueType>
void IA_ValueSet<ValueType>::make_set() {
d231 1
a231 1
	qsort(this->value_array, this->size, sizeof(ValueType),
d240 2
a241 2
template <class ValueType>
void IA_ValueSet<ValueType>::remove_dup() {
d243 1
a243 1
    ValueType *clean_array = new ValueType[this->size - count_dup()];
d258 2
a259 2
template <class ValueType>
int IA_ValueSet<ValueType>::count_dup() const {
d267 3
a269 3
template <class ValueType>
IA_ValueSet<ValueType>& 
IA_ValueSet<ValueType>::operator=  (const IA_ValueSet<ValueType>& vs) {
d286 1
a286 1
	this->value_array = new ValueType[vs.size];
d309 3
a311 3
template <class ValueType>
IA_ValueSet<ValueType> 
IA_ValueSet<ValueType>::operator| (const IA_ValueSet<ValueType> &right) const {
d315 1
a315 1
	return IA_ValueSet<ValueType>(*this);
d317 1
a317 1
    ValueType* temp = new ValueType[this->size + right.size];
d332 1
a332 1
    return IA_ValueSet<ValueType>(temp, ci);
d336 4
a339 4
template <class ValueType>
IA_ValueSet<ValueType> 
IA_ValueSet<ValueType>::operator| (const ValueType &right) const {
    return *this | IA_ValueSet<ValueType>(right);
d342 4
a345 4
template <class ValueType>
IA_ValueSet<ValueType> 
operator| (const ValueType &left, const IA_ValueSet<ValueType> &right) {
    return IA_ValueSet<ValueType>(left) | right;
d353 3
a355 3
template <class ValueType>
IA_ValueSet<ValueType> 
IA_ValueSet<ValueType>::operator& (const IA_ValueSet<ValueType> &right)  const {
d359 1
a359 1
	return IA_ValueSet<ValueType>();
d361 4
a364 4
	ValueType	lmax = this->max();
	ValueType	lmin = this->min();
	ValueType	rmax = right.max();
	ValueType	rmin = right.min();
d367 1
a367 1
	    return IA_ValueSet<ValueType>();
d370 1
a370 1
	return IA_ValueSet<ValueType>(*this);
d372 1
a372 1
    ValueType* temp = new ValueType[this->card() < right.card() 
d385 1
a385 1
    return IA_ValueSet<ValueType>(temp, ci);
d389 3
a391 3
template <class ValueType>
IA_ValueSet<ValueType> 
IA_ValueSet<ValueType>::operator& (const ValueType &right) const {
d393 1
a393 1
	return IA_ValueSet<ValueType>(right);
d395 1
a395 1
	return IA_ValueSet<ValueType>();
d398 3
a400 3
template <class ValueType>
IA_ValueSet<ValueType> 
operator& (const ValueType &left, const IA_ValueSet<ValueType> &right) {
d402 1
a402 1
	return IA_ValueSet<ValueType>(left);
d404 1
a404 1
	return IA_ValueSet<ValueType>();
d412 3
a414 3
template <class ValueType>
IA_ValueSet<ValueType> 
IA_ValueSet<ValueType>::operator/ (const IA_ValueSet<ValueType> &right) const {
d418 1
a418 1
	return IA_ValueSet<ValueType>();
d420 1
a420 1
	return IA_ValueSet<ValueType>(*this);
d422 1
a422 1
	return IA_ValueSet<ValueType>();
d424 1
a424 1
    ValueType* temp = new ValueType[this->size];
d439 1
a439 1
    return IA_ValueSet<ValueType>(temp, ci);
d443 4
a446 4
template <class ValueType>
IA_ValueSet<ValueType> 
IA_ValueSet<ValueType>::operator/ (const ValueType &right) const {
    return *this / IA_ValueSet<ValueType>(right);
d449 3
a451 3
template <class ValueType>
IA_ValueSet<ValueType> 
operator/ (const ValueType &left, const IA_ValueSet<ValueType> &right) {
d453 1
a453 1
	return IA_ValueSet<ValueType>();
d455 1
a455 1
	return IA_ValueSet<ValueType>(left);
d463 3
a465 3
template <class ValueType>
IA_ValueSet<ValueType> 
IA_ValueSet<ValueType>::operator^ (const IA_ValueSet<ValueType> &right) const {
d469 1
a469 1
	return IA_ValueSet<ValueType>(right);
d471 1
a471 1
	return IA_ValueSet<ValueType>(*this);
d473 1
a473 1
	return IA_ValueSet<ValueType>();
d475 1
a475 1
    ValueType* temp = new ValueType[this->size + right.size];
d494 1
a494 1
    return IA_ValueSet<ValueType>(temp, ci);
d497 3
a499 3
template <class ValueType>
IA_ValueSet<ValueType> 
IA_ValueSet<ValueType>::operator^ (const ValueType &right) const {
d502 1
a502 1
	return IA_ValueSet<ValueType>(*this / right);
d504 1
a504 1
	return IA_ValueSet<ValueType>(*this | right);
d507 3
a509 3
template <class ValueType>
IA_ValueSet<ValueType> 
operator^ (const ValueType &left, const IA_ValueSet<ValueType> &right) {
d512 1
a512 1
	return IA_ValueSet<ValueType>(right / left);
d514 1
a514 1
	return IA_ValueSet<ValueType>(right | left);
d522 1
a522 1
template <class ValueType> 
d524 1
a524 1
IA_ValueSet<ValueType>::operator<= (const IA_ValueSet<ValueType> &right) const {
d553 1
a553 1
template <class ValueType> 
d555 1
a555 1
IA_ValueSet<ValueType>::operator<= (const ValueType &right) const {
d564 1
a564 1
template <class ValueType> 
d566 1
a566 1
operator<= (const ValueType &left, const IA_ValueSet<ValueType> &right){
d578 1
a578 1
template <class ValueType>
d580 1
a580 1
IA_ValueSet<ValueType>::operator>= (const IA_ValueSet<ValueType> &right) const {
d585 1
a585 1
template <class ValueType>
d587 1
a587 1
IA_ValueSet<ValueType>::operator>= (const ValueType &right) const {
d591 1
a591 1
template <class ValueType>
d593 1
a593 1
operator>= (const ValueType &left, const IA_ValueSet<ValueType> &right){
d602 1
a602 1
template <class ValueType> 
d604 1
a604 1
IA_ValueSet<ValueType>::operator< (const IA_ValueSet<ValueType> &right) const {
d633 1
a633 1
template <class ValueType> 
d635 1
a635 1
IA_ValueSet<ValueType>::operator< (const ValueType &) const {
d640 1
a640 1
template <class ValueType> 
d642 1
a642 1
operator< (const ValueType &left, const IA_ValueSet<ValueType> &right){
d653 1
a653 1
template <class ValueType>
d655 1
a655 1
IA_ValueSet<ValueType>::operator> (const IA_ValueSet<ValueType> &right) const {
d661 1
a661 1
template <class ValueType>
d663 1
a663 1
IA_ValueSet<ValueType>::operator> (const ValueType &right) const {
d667 1
a667 1
template <class ValueType>
d669 1
a669 1
operator> (const ValueType &left, const IA_ValueSet<ValueType> &right){
d678 1
a678 1
template <class ValueType> 
d680 1
a680 1
IA_ValueSet<ValueType>::operator== (const IA_ValueSet<ValueType> &right) const {
d691 1
a691 1
template <class ValueType> 
d693 1
a693 1
IA_ValueSet<ValueType>::operator== (const ValueType &right) const {
d700 1
a700 1
template <class ValueType> 
d702 1
a702 1
operator== (const ValueType &left, const IA_ValueSet<ValueType> &right){
d714 1
a714 1
template <class ValueType> 
d716 1
a716 1
IA_ValueSet<ValueType>::operator!= (const IA_ValueSet<ValueType> &right) const {
d721 1
a721 1
template <class ValueType> 
d723 1
a723 1
IA_ValueSet<ValueType>::operator!= (const ValueType &right) const {
d727 1
a727 1
template <class ValueType> 
d729 1
a729 1
operator!= (const ValueType &left, const IA_ValueSet<ValueType> &right){
d738 1
a738 1
template <class ValueType>
d744 1
a744 1
compare(const IA_ValueSet<ValueType> &lhs, const IA_ValueSet<ValueType> &rhs) {
d756 2
a757 2
template <class ValueType>
ostream& operator<< (ostream& st, const IA_ValueSet<ValueType>& vs) {
@


1.18
log
@Added iterators.
changed ValueType to T.
removed the binary ops between Sets and scalars since they were
inaccessible to users and unused by the IA_Set class.
@
text
@d10 6
d736 3
d740 1
@


1.17
log
@Changed IA::LatticeRelation to IA_LatticeRelation since the mac
doesn't deal with enums defined inside of templated classes.  Not
that IA_LatticeRelation is #defined to IA::LatticeRelation in
ia.h . . .
@
text
@d10 6
d106 1
d287 13
d326 1
d338 1
d340 4
d379 1
d397 1
d399 4
d433 1
d448 1
d450 4
d487 1
a487 1

d507 1
d509 4
d543 1
d563 1
d565 4
d575 1
d587 1
d589 4
d623 1
d638 5
d651 1
a651 1

d663 1
d665 4
d681 1
d699 1
d701 4
d711 1
d723 5
d730 1
a730 1
IA_LatticeRelation
@


1.16
log
@Handle some difficulties with G++ instantiation of static data members.
@
text
@d10 3
d652 1
a652 1
IA::LatticeRelation
@


1.15
log
@fix to operator<.  All this code needs a review.
@
text
@d10 3
d98 1
d101 1
@


1.14
log
@Logic errors in < partly fixed.
@
text
@d10 3
d540 3
a542 1
    if (this == &right) return 0;
@


1.13
log
@Work around bug in CFront float formal parameters.
Need dummy for type().
@
text
@d10 4
d533 2
a536 2
    if (right.empty())
	return 0;
d551 1
a551 4
	if (ri == right.size)
	    return 0;
	else
	    return 1;
@


1.12
log
@use value_type_compare any place you need a comparison
of values.
@
text
@d10 4
d88 3
d92 2
a93 2
int IA_ValueSet<ValueType>::contains(ValueType e) const {
    
d95 2
a96 2
	
    return ((int) bsearch((ValueType *)(&e), 
d100 1
a100 1
}    
@


1.11
log
@Fix array constructor.
@
text
@d9 4
a12 1
    $Log:	ValueSet.c,v $
d268 1
a268 1
	if (this->value_array[li] < right.value_array[ri])
d303 9
a311 2
    if ((this->max() < right.min()) || (this->min() > right.max()))
	return IA_ValueSet<ValueType>();
d319 1
a319 1
	if (this->value_array[li] < right.value_array[ri])
d362 4
a365 2
    while ((li < this->size) && (ri < right.size))
	if (this->value_array[li] < right.value_array[ri])
d368 1
a368 1
	    if (this->value_array[li] == right.value_array[ri]) {
a369 1
	    }
d372 1
d407 4
a410 2
    while ((li < this->size) && (ri < right.size)) 
	if (this->value_array[li] < right.value_array[ri])
d412 7
a418 7
	else
	    if (this->value_array[li] > right.value_array[ri])
		temp[ci++] = right.value_array[ri++];
	    else { 
		li++;
		ri++;
	    }
d460 3
a462 1
	if (this->value_array[li] < right.value_array[ri])
d464 5
a468 2
	if (this->value_array[li] == right.value_array[ri++])
	    li++;
d528 3
a530 1
	if (this->value_array[li] < right.value_array[ri])
d532 5
a536 2
	if (this->value_array[li] == right.value_array[ri++])
	    li++;
@


1.10
log
@Copyright Notices
@
text
@d10 3
d77 2
a78 1
#include <stream.h>
d170 1
a170 1
IA_ValueSet<ValueType>::IA_ValueSet(ValueType* const ar, unsigned int sz) {
@


1.9
log
@move the special functions into another module
@
text
@d3 5
d10 3
@


1.8
log
@The LatticeRelation that was causing a compiler bug is now
used from IA instead of IA_ValueSet<T>.
@
text
@d1 2
d5 4
a68 14
IA_ValueSet<int> value_range(int v0, int v1) {
    IA_ValueSet<int> vs;
    int sz = v1 - v0;
    
    if (sz < 0)
	return IA_ValueSet<int>();
    if (sz == 0)
	return IA_ValueSet<int>(v0);
    int *ret_array = new int[++sz];
    for (int i = 0; i < sz; i++)
	ret_array[i] = v0+i;
    return IA_ValueSet<int>(ret_array, sz);
}

d513 1
a513 1
IA_ValueSet<ValueType>::operator< (const ValueType &right) const {
@


1.7
log
@added output method for testing.
Also added ifdefs since template implementation file are really
"headers".  We were having problems with multiple inclusion.
@
text
@d3 5
d603 1
a603 1
IA_ValueSet<ValueType>::LatticeRelation
d607 1
a607 1
       return IA_ValueSet<ValueType>::EQUAL;
d609 1
a609 1
       return IA_ValueSet<ValueType>::P_SUBSET;
d611 2
a612 2
       return IA_ValueSet<ValueType>::P_SUPERSET;
   return IA_ValueSet<ValueType>::NO_REL;
@


1.6
log
@ Renamed class ValueSet to IA_ValueSet
@
text
@d3 3
d52 3
d610 16
@


1.5
log
@fixed operator "<=" on two value sets
@
text
@d3 3
d52 2
a53 2
ValueSet<int> value_range(int v0, int v1) {
    ValueSet<int> vs;
d57 1
a57 1
	return ValueSet<int>();
d59 1
a59 1
	return ValueSet<int>(v0);
d63 1
a63 1
    return ValueSet<int>(ret_array, sz);
d67 1
a67 1
int ValueSet<ValueType>::contains(ValueType e) const {
d78 1
a78 1
int ValueSetComparator<ValueType>::value_type_compare(
d89 1
a89 1
ValueSet<ValueType>::ValueSet(const ValueSet<ValueType>& vs) {
d101 1
a101 1
ValueSet<ValueType>::ValueSet(ValueType v0) {
d108 1
a108 1
ValueSet<ValueType>::ValueSet(ValueType v0, ValueType v1) {
d118 1
a118 1
ValueSet<ValueType>::ValueSet(ValueType v0, ValueType v1, ValueType v2) {
d129 1
a129 1
ValueSet<ValueType>::ValueSet(ValueType v0, ValueType v1,ValueType v2, 
d142 1
a142 1
ValueSet<ValueType>::ValueSet(ValueType v0, ValueType v1, ValueType v2, 
d155 1
a155 1
ValueSet<ValueType>::ValueSet(ValueType* const ar, unsigned int sz) {
d171 1
a171 1
void ValueSet<ValueType>::make_set() {
d185 1
a185 1
void ValueSet<ValueType>::remove_dup() {
d203 1
a203 1
int ValueSet<ValueType>::count_dup() const {
d212 2
a213 2
ValueSet<ValueType>& 
ValueSet<ValueType>::operator=  (const ValueSet<ValueType>& vs) {
d241 2
a242 2
ValueSet<ValueType> 
ValueSet<ValueType>::operator| (const ValueSet<ValueType> &right) const {
d246 1
a246 1
	return ValueSet<ValueType>(*this);
d263 1
a263 1
    return ValueSet<ValueType>(temp, ci);
d267 3
a269 3
ValueSet<ValueType> 
ValueSet<ValueType>::operator| (const ValueType &right) const {
    return *this | ValueSet<ValueType>(right);
d273 3
a275 3
ValueSet<ValueType> 
operator| (const ValueType &left, const ValueSet<ValueType> &right) {
    return ValueSet<ValueType>(left) | right;
d279 2
a280 2
ValueSet<ValueType> 
ValueSet<ValueType>::operator& (const ValueSet<ValueType> &right)  const {
d284 1
a284 1
	return ValueSet<ValueType>();
d286 1
a286 1
	return ValueSet<ValueType>();
d288 1
a288 1
	return ValueSet<ValueType>(*this);
d303 1
a303 1
    return ValueSet<ValueType>(temp, ci);
d307 2
a308 2
ValueSet<ValueType> 
ValueSet<ValueType>::operator& (const ValueType &right) const {
d310 1
a310 1
	return ValueSet<ValueType>(right);
d312 1
a312 1
	return ValueSet<ValueType>();
d316 2
a317 2
ValueSet<ValueType> 
operator& (const ValueType &left, const ValueSet<ValueType> &right) {
d319 1
a319 1
	return ValueSet<ValueType>(left);
d321 1
a321 1
	return ValueSet<ValueType>();
d325 2
a326 2
ValueSet<ValueType> 
ValueSet<ValueType>::operator/ (const ValueSet<ValueType> &right) const {
d330 1
a330 1
	return ValueSet<ValueType>();
d332 1
a332 1
	return ValueSet<ValueType>(*this);
d334 1
a334 1
	return ValueSet<ValueType>();
d349 1
a349 1
    return ValueSet<ValueType>(temp, ci);
d353 3
a355 3
ValueSet<ValueType> 
ValueSet<ValueType>::operator/ (const ValueType &right) const {
    return *this / ValueSet<ValueType>(right);
d359 2
a360 2
ValueSet<ValueType> 
operator/ (const ValueType &left, const ValueSet<ValueType> &right) {
d362 1
a362 1
	return ValueSet<ValueType>();
d364 1
a364 1
	return ValueSet<ValueType>(left);
d368 2
a369 2
ValueSet<ValueType> 
ValueSet<ValueType>::operator^ (const ValueSet<ValueType> &right) const {
d373 1
a373 1
	return ValueSet<ValueType>(right);
d375 1
a375 1
	return ValueSet<ValueType>(*this);
d377 1
a377 1
	return ValueSet<ValueType>();
d396 1
a396 1
    return ValueSet<ValueType>(temp, ci);
d400 2
a401 2
ValueSet<ValueType> 
ValueSet<ValueType>::operator^ (const ValueType &right) const {
d404 1
a404 1
	return ValueSet<ValueType>(*this / right);
d406 1
a406 1
	return ValueSet<ValueType>(*this | right);
d410 2
a411 2
ValueSet<ValueType> 
operator^ (const ValueType &left, const ValueSet<ValueType> &right) {
d414 1
a414 1
	return ValueSet<ValueType>(right / left);
d416 1
a416 1
	return ValueSet<ValueType>(right | left);
d421 1
a421 1
ValueSet<ValueType>::operator<= (const ValueSet<ValueType> &right) const {
d446 1
a446 1
ValueSet<ValueType>::operator<= (const ValueType &right) const {
d457 1
a457 1
operator<= (const ValueType &left, const ValueSet<ValueType> &right){
d466 1
a466 1
ValueSet<ValueType>::operator>= (const ValueSet<ValueType> &right) const {
d472 1
a472 1
ValueSet<ValueType>::operator>= (const ValueType &right) const {
d478 1
a478 1
operator>= (const ValueType &left, const ValueSet<ValueType> &right){
d484 1
a484 1
ValueSet<ValueType>::operator< (const ValueSet<ValueType> &right) const {
d510 1
a510 1
ValueSet<ValueType>::operator< (const ValueType &right) const {
d517 1
a517 1
operator< (const ValueType &left, const ValueSet<ValueType> &right){
d525 1
a525 1
ValueSet<ValueType>::operator> (const ValueSet<ValueType> &right) const {
d533 1
a533 1
ValueSet<ValueType>::operator> (const ValueType &right) const {
d539 1
a539 1
operator> (const ValueType &left, const ValueSet<ValueType> &right){
d545 1
a545 1
ValueSet<ValueType>::operator== (const ValueSet<ValueType> &right) const {
d557 1
a557 1
ValueSet<ValueType>::operator== (const ValueType &right) const {
d566 1
a566 1
operator== (const ValueType &left, const ValueSet<ValueType> &right){
d575 1
a575 1
ValueSet<ValueType>::operator!= (const ValueSet<ValueType> &right) const {
d581 1
a581 1
ValueSet<ValueType>::operator!= (const ValueType &right) const {
d587 1
a587 1
operator!= (const ValueType &left, const ValueSet<ValueType> &right){
d592 2
a593 2
ValueSet<ValueType>::LatticeRelation
compare(const ValueSet<ValueType> &lhs, const ValueSet<ValueType> &rhs) {
d596 1
a596 1
       return ValueSet<ValueType>::EQUAL;
d598 1
a598 1
       return ValueSet<ValueType>::P_SUBSET;
d600 2
a601 2
       return ValueSet<ValueType>::P_SUPERSET;
   return ValueSet<ValueType>::NO_REL;
@


1.4
log
@*** empty log message ***
@
text
@d3 3
d433 5
@


1.3
log
@added comments to remove_dup and count_dup functions.
changed NULL to 0.
@
text
@d3 4
@


1.2
log
@Included value_range function as an independent function
function contains() now returns 1 or 0
added keyword 'const' to function count_dup
added keyword 'const' to all member operators
added definition for operators '>' and '<'
added definition for function compare
@
text
@d3 8
d82 1
a82 1
	this->value_array = NULL;
d148 1
a148 1
	this->value_array = NULL;
d171 3
d190 2
d210 2
a211 2
	delete[] this->value_array;  // OK even if value_array already NULL
	this->value_array = NULL; 
@


1.1
log
@Initial revision
@
text
@d1 5
a5 2
/*  $RCSfile: ValueSet.C,v $
    $Log:	ValueSet.C,v $
@
