// Copyright (C) 1996 DIMACS Center, Rutgers, The State University of New Jersey
// Author(s): Jonathan Berry

// This software is copyrighted by the DIMACS Center at Rutgers, The State
// University of New Jersey.  IT IS PROVIDED AS IS, AND THE AUTHORS, DIMACS, AND
// RUTGERS, THE STATE UNIVERSITY OF NEW JERSEY  DISCLAIM
// ALL LIABILITY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
// DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
// DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.

// THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.  THIS SOFTWARE
// IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
// NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
// MODIFICATIONS.

// The authors hereby grant permission to use, copy, modify, distribute,
// and license this software and its documentation for any purpose, provided
// that existing copyright notices are retained in all copies and that this
// notice is included verbatim in any distributions. No written agreement,
// license, or royalty fee is required for any of the authorized uses.
// Modifications to this software may be copyrighted by their authors
// and need not follow the licensing terms described here, provided that
// the new terms are clearly indicated on the first page of each file where
// they apply.

// Last File Update: 31-Jul-1996
// 

#ifndef Set_h
#define Set_h

#include <LINK/basic/MSet.h>

#ifndef DEFAULT_SET_IMPL 
#define DEFAULT_SET_IMPL SortedList
#endif


template <class Item, class Impl> 
class SetBase : public MSetBase<Item, Impl> {

public:
    SetBase() : MSetBase<Item, Impl>() {} 
    SetBase(const SetBase<Item,Impl>& s);
    SetBase(const Collection<Item>&c);
    SetBase(const Container<Item>&c);

    SetBase<Item,Impl>&	operator=(const SetBase<Item,Impl>& c);
    SetBase<Item,Impl>&	operator=(const Collection<Item>& c);
    //SetBase<Item,Impl>& copy(const SetBase<Item,Impl>& c) 
    //				{ *this = c; return *this;}

    DataType	type() const		{ return SETCOL; }
    void	insert(Item e);	        	
    void	append(Item e);

    //MSetBase<Item,Impl>	unions(Collection<Item>& c);
    //MSetBase<Item,Impl>	operator+(Collection<Item>& c);
    //MSetBase<Item,Impl>	intersection(Collection<Item>& c);
    //MSetBase<Item,Impl>	operator^(Collection<Item>& c);
    //MSetBase<Item,Impl>	difference(Collection<Item>& c);
    //MSetBase<Item,Impl>	operator-(Collection<Item>& c);

    //MSetBase<Item,Impl>	unions(SetBase<Item,Impl>& c);
    //MSetBase<Item,Impl>	operator+(SetBase<Item,Impl>& c);
    //MSetBase<Item,Impl>	intersection(SetBase<Item,Impl>& c);
    //MSetBase<Item,Impl>	operator^(SetBase<Item,Impl>& c);
    //MSetBase<Item,Impl>	difference(SetBase<Item,Impl>& c);
    //MSetBase<Item,Impl>	operator-(SetBase<Item,Impl>& c);

    int				occurrences(Item item) const;
    Bool			permutationQ() const;

    ostream&	display(ostream& os) const;
    Collection<Item>*   newEmpty() const 
				{return new SetBase<Item,Impl>; }

protected:
    void	newSet(SetBase<Item,Impl>* s);
    //friend class CollectionWrapper<Item>;
};


template <class Item>
class Set : public SetBase<Item, DEFAULT_SET_IMPL<Item> > {
public:
    Set() {}
    Set(const Set<Item>& c) : 
			SetBase<Item, DEFAULT_SET_IMPL<Item> >(c) {}
    Set(const Collection<Item>& c) :
			SetBase<Item, DEFAULT_SET_IMPL<Item> >(c) {}
    Set(const Container<Item>& c) :
			SetBase<Item, DEFAULT_SET_IMPL<Item> >(c) {}


    Set<Item>&        operator=(const Set<Item>& s);
    Set<Item>&        operator=(const Collection<Item>& s);
    //friend class CollectionWrapper<Item>;
};


#define SET(etype, itype) SetBase<etype, itype<etype> >

#ifdef DEFINE_TEMPLATE
#include <LINK/basic/Set.cc>
#endif


#endif
