head	1.6;
access;
symbols
	bobbase:1.5
	bob:1.5.1
	r2_1:1.3
	r2_0:1.3
	r1_1_beta:1.2
	r1_1_alpha:1.1
	r1_0:1.1
	r0_11:1.1;
locks; strict;
comment	@// @;


1.6
date	94.10.31.18.50.13;	author fjsoria;	state Exp;
branches;
next	1.5;

1.5
date	94.10.03.19.38.09;	author thoth;	state Exp;
branches
	1.5.1.1;
next	1.4;

1.4
date	94.10.03.17.50.47;	author thoth;	state Exp;
branches;
next	1.3;

1.3
date	94.08.22.15.10.59;	author thoth;	state Exp;
branches;
next	1.2;

1.2
date	94.07.25.16.45.00;	author thoth;	state Exp;
branches;
next	1.1;

1.1
date	94.03.21.23.06.36;	author thoth;	state Exp;
branches;
next	;

1.5.1.1
date	94.10.12.17.21.27;	author thoth;	state Exp;
branches;
next	1.5.1.2;

1.5.1.2
date	94.12.08.14.44.44;	author thoth;	state Exp;
branches;
next	;


desc
@Container class for the generic Set.
@


1.6
log
@put guards around #include IntPS DblPS, g++
will require all members to be instantiated
@
text
@// Emacs -*- C++ -*-

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

//
// $Log: Set.h,v $
// Revision 1.5  1994/10/03  19:38:09  thoth
// Get rid of redundant scalar-set operations in preparation for operator
// table.
//
// Revision 1.4  1994/10/03  17:50:47  thoth
// Added predicate sets.
//
// Revision 1.3  1994/08/22  15:10:59  thoth
// DOS-inspired name rework
//
// Revision 1.2  1994/07/25  16:45:00  thoth
// Name sanitization.
//
// Revision 1.1  1994/03/21  23:06:36  thoth
// Initial revision
//

#ifndef IA_Set_h_
#define IA_Set_h_

#include "BaseSet.h"


template <class T> class IA_Set;

template <class T> class IA_SetIter;

template <class T> int operator< (const IA_Set<T>&, const IA_Set<T>&);
template <class T> int operator<= (const IA_Set<T>&, const IA_Set<T>&);
template <class T> int operator== (const IA_Set<T>&, const IA_Set<T>&);

template <class T>
class IA_Set {

    friend class IA_SetIter<T>;

    IA_BaseSet<T>	*bsp;

    void set_and_reference(IA_BaseSet<T> *);
    void disassociate();

    IA_Set(IA_BaseSet<T> * s) { set_and_reference(s); }
public:
    IA_Set();
    IA_Set(const IA_Set &);

    ~IA_Set();

    IA_Set& operator= (const IA_Set&);
    
    IA_Set(T);
    IA_Set(T, T);
    IA_Set(T, T, T);
    IA_Set(T, T, T, T);
    IA_Set(T, T, T, T, T);
    IA_Set( const T*, unsigned int);

    IA_Set(int (*)(T));
    IA_Set(int (*)(const T&));

    // card: cardinality, number of elements in the set
    
    unsigned int card() const {return bsp->card();}
    
    // contains: predicate for testing membership of an element in a set
    
    int contains(T t) const { return bsp->contains(t); }
    
    // min: minimum element of the set
    
    T min() const {
	return bsp->min();
    }
    
    // max: maximum element of the set
    
    T max() const {
	return bsp->max();
    }

    // choice: some element from the set, we don\'t care which one
    T choice() const {
	return bsp->choice();
    }
    
    // empty: predicate for testing emptiness of a set 
    
    int empty() const {return bsp->empty();}

    friend IA_Set<T> operator| (const IA_Set<T> &, const IA_Set<T>&);
    friend IA_Set<T> operator& (const IA_Set<T> &, const IA_Set<T>&);
    friend IA_Set<T> operator/ (const IA_Set<T> &, const IA_Set<T>&);
    friend IA_Set<T> operator^ (const IA_Set<T> &, const IA_Set<T>&);
#if 0
    IA_Set<T> operator|  (const T&) const;
    IA_Set<T> operator&  (const T&) const;
    IA_Set<T> operator/  (const T&) const;
    IA_Set<T> operator^  (const T&) const;
    
    friend IA_Set<T>	
	operator|  (const T&, const IA_Set<T>&);
    friend IA_Set<T>	
	operator&  (const T&, const IA_Set<T>&);
    friend IA_Set<T>	
	operator/  (const T&, const IA_Set<T>&);
    friend IA_Set<T>	
	operator^  (const T&, const IA_Set<T>&);
#endif

    // The range of return values for this compare function does not include
    // all the enumerated values.
    
    friend int operator<  (const IA_Set<T>&, const IA_Set<T>&);
    friend int operator<= (const IA_Set<T>&, const IA_Set<T>&);
    friend int operator== (const IA_Set<T>&, const IA_Set<T>&);
    friend int operator!= (const IA_Set<T>&, const IA_Set<T>&);
    friend int operator>= (const IA_Set<T>&, const IA_Set<T>&);
    friend int operator> (const IA_Set<T>&, const IA_Set<T>&);

    friend IA::LatticeRelation
	compare(const IA_Set<T>&,
		const IA_Set<T>&);
};

//
//

template <class T> inline int operator>= (const IA_Set<T>&lhs,
				   const IA_Set<T>&rhs) {
    return rhs <= lhs ;
}
template <class T> inline int operator> (const IA_Set<T>&lhs,
				  const IA_Set<T>&rhs) {
    return rhs < lhs ;
}
template <class T> inline int operator!= (const IA_Set<T>&lhs,
				   const IA_Set<T>&rhs) {
    return !(lhs == rhs) ;
}

//
//

template <class T> inline int operator< (const T&lhs, const IA_Set<T>&rhs) {
    return IA_Set<T>(lhs) < rhs;
}
template <class T> inline int operator<= (const T&lhs, const IA_Set<T>&rhs) {
    return IA_Set<T>(lhs) <= rhs;
}
template <class T> inline int operator== (const T&lhs, const IA_Set<T>&rhs) {
    return IA_Set<T>(lhs) == rhs;
}
template <class T> inline int operator>= (const T&lhs, const IA_Set<T>&rhs) {
    return rhs <= IA_Set<T>(lhs);
}
template <class T> inline int operator> (const T&lhs, const IA_Set<T>&rhs) {
    return rhs <IA_Set<T>(lhs);
}
template <class T> inline int operator!= (const T&lhs, const IA_Set<T>&rhs) {
    return !(IA_Set<T>(lhs) == rhs);
}

//
//

template <class T> inline int operator< (const IA_Set<T>&lhs, const T&rhs) {
    return lhs < IA_Set<T>(rhs);
}
template <class T> inline int operator<= (const IA_Set<T>&lhs, const T&rhs) {
    return lhs <= IA_Set<T>(rhs);
}
template <class T> inline int operator== (const IA_Set<T>&lhs, const T&rhs) {
    return lhs == IA_Set<T>(rhs);
}
template <class T> inline int operator>= (const IA_Set<T>&lhs, const T&rhs) {
    return IA_Set<T>(rhs) <= lhs ;
}
template <class T> inline int operator> (const IA_Set<T>&lhs, const T&rhs) {
    return IA_Set<T>(rhs) < lhs ;
}
template <class T> inline int operator!= (const IA_Set<T>&lhs, const T&rhs) {
    return !(lhs == IA_Set<T>(rhs)) ;
}

//
//
//

#if 1

 /* We shouldn't need these inlines, but template functions are still
    touchy under CFront */

template <class T> inline IA_Set<T> operator|(T lhs, const IA_Set<T> & rhs) {
    return IA_Set<T>(lhs)|rhs;
}

template <class T> inline IA_Set<T> operator&(T lhs, const IA_Set<T> & rhs) {
    return IA_Set<T>(lhs)&rhs;
}

template <class T> inline IA_Set<T> operator^(T lhs, const IA_Set<T> & rhs) {
    return IA_Set<T>(lhs)^rhs;
}

template <class T> inline IA_Set<T> operator/(T lhs, const IA_Set<T> & rhs) {
    return IA_Set<T>(lhs)/rhs;
}

//
//
//

template <class T> inline IA_Set<T> operator|(const IA_Set<T> & lhs, T rhs) {
    return lhs|IA_Set<T>(rhs);
}

template <class T> inline IA_Set<T> operator&(const IA_Set<T> & lhs, T rhs) {
    return lhs&IA_Set<T>(rhs);
}

template <class T> inline IA_Set<T> operator^(const IA_Set<T> & lhs, T rhs) {
    return lhs^IA_Set<T>(rhs);
}

template <class T> inline IA_Set<T> operator/(const IA_Set<T> & lhs, T rhs) {
    return lhs/IA_Set<T>(rhs);
}

#endif

//
//
 
#ifdef NO_INST_TEMPLATES
#ifndef SUPPRESS_INCLUDE
#include "IntPS.h"
#include "DblPS.h"
#endif
#else
// g++ does not support the following , left here as a reminder
//class IA_Set< IA_Point<int> >;
//class IA_Set< IA_Point<double> >;

#endif

#endif
@


1.5
log
@Get rid of redundant scalar-set operations in preparation for operator
table.
@
text
@d10 4
d243 2
a244 1

d248 6
@


1.5.1.1
log
@Added ClosureSets.
Added op= for binary operations &|^/ .
@
text
@a9 4
// Revision 1.5  1994/10/03  19:38:09  thoth
// Get rid of redundant scalar-set operations in preparation for operator
// table.
//
d31 2
a36 5

template <class T> class IA_SetIter;
template <class T> class IA_ClosureSet;


a64 1
    IA_Set(const IA_ClosureSet<T> &);
d97 1
d99 15
a113 20
    friend IA_Set<T> operator/ (const IA_Set<T> &, const IA_Set<T>&);

    IA_Set<T> & operator|= ( const IA_Set<T> & s ) {
	*this = *this | s;		return *this;	}
    IA_Set<T> & operator&= ( const IA_Set<T> & s ) {
	*this = *this & s;		return *this;	}
    IA_Set<T> & operator^= ( const IA_Set<T> & s ) {
	*this = *this ^ s;		return *this;	}
    IA_Set<T> & operator/= ( const IA_Set<T> & s ) {
	*this = *this / s;		return *this;	}

    IA_Set<T> & operator|= ( T s ) {
	*this = *this | s;		return *this;	}
    IA_Set<T> & operator&= ( T s ) {
	*this = *this & s;		return *this;	}
    IA_Set<T> & operator^= ( T s ) {
	*this = *this ^ s;		return *this;	}
    IA_Set<T> & operator/= ( T s ) {
	*this = *this / s;		return *this;	}

@


1.5.1.2
log
@New extensive() method.
Comparison rework to handle more computable cases.
@
text
@a9 4
// Revision 1.5.1.1  1994/10/12  17:21:27  thoth
// Added ClosureSets.
// Added op= for binary operations &|^/ .
//
a73 2
    int extensive() const { return bsp->extensive(); }

d107 1
a107 1
#if 0
d125 1
a125 1
#endif
d130 6
d145 11
a155 29
template <class T> inline
int operator<  (const IA_Set<T>&a, const IA_Set<T>&b) {
    IA::LatticeRelation	cmp = compare(a, b);
    return cmp==IA::P_SUBSET;
}
template <class T> inline
int operator<=  (const IA_Set<T>&a, const IA_Set<T>&b) {
    IA::LatticeRelation	cmp = compare(a, b);
    return cmp==IA::P_SUBSET || cmp==IA::MP_SUBSET || cmp==IA::EQUAL;
}
template <class T> inline
int operator==  (const IA_Set<T>&a, const IA_Set<T>&b) {
    IA::LatticeRelation	cmp = compare(a, b);
    return cmp==IA::EQUAL;
}
template <class T> inline
int operator!=  (const IA_Set<T>&a, const IA_Set<T>&b) {
    IA::LatticeRelation	cmp = compare(a, b);
    return cmp==IA::P_SUBSET || cmp==IA::P_SUPERSET || cmp==IA::NO_REL;
}
template <class T> inline
int operator>  (const IA_Set<T>&a, const IA_Set<T>&b) {
    IA::LatticeRelation	cmp = compare(a, b);
    return cmp==IA::P_SUPERSET;
}
template <class T> inline
int operator>=  (const IA_Set<T>&a, const IA_Set<T>&b) {
    IA::LatticeRelation	cmp = compare(a, b);
    return cmp==IA::P_SUPERSET || cmp==IA::MP_SUPERSET || cmp==IA::EQUAL;
a157 1

a251 2
#ifdef __CFRONT__

a255 2

#endif // __CFRONT__
@


1.4
log
@Added predicate sets.
@
text
@d10 3
d95 5
a99 5
    IA_Set<T> operator|  (const IA_Set<T>&) const;
    IA_Set<T> operator&  (const IA_Set<T>&) const;
    IA_Set<T> operator/  (const IA_Set<T>&) const;
    IA_Set<T> operator^  (const IA_Set<T>&) const;

d113 1
d189 47
@


1.3
log
@DOS-inspired name rework
@
text
@d10 3
d28 2
d36 3
d60 3
d83 1
a83 1
    // choice: some element from the set, we don't care which one
d91 1
a91 1
    
d96 1
a96 1
    
d103 1
a103 1
    operator|  (const T&, const IA_Set<T>&);
d105 1
a105 1
    operator&  (const T&, const IA_Set<T>&);
d107 1
a107 1
    operator/  (const T&, const IA_Set<T>&);
d109 2
a110 2
    operator^  (const T&, const IA_Set<T>&);
    
d122 2
a123 2
    compare(const IA_Set<T>&,
	    const IA_Set<T>&);
@


1.2
log
@Name sanitization.
@
text
@d10 3
d179 2
a180 2
#include "IntPointSet.h"
#include "DoublePointSet.h"
@


1.1
log
@Initial revision
@
text
@d9 4
a12 1
// $Log$
d177 1
a177 1
#include "FloatPointSet.h"
@
