// MapElement.H
// John Ringland 9/18/95
//		 9/27/95
//		10/19/95  Tested.

#ifndef MAPELEMENT_H
#define MAPELEMENT_H

#include "DE.H"
#include "DELList.H"
//#include <iostream.h>
#include <iostream>
using namespace std;


class MapElement
{
   private:
	DE src;   	// This is the DE whose image is the DELList
	DELList img;

   public:
	const DE& source() const { return src; }
	DE& source() { return src; }

	DELList& image()  { return img; } 
	const DELList& image() const { return img; } 

	MapElement(const DE& s,const DELList& L)
	:  src(s),img(L)
	{}
	MapElement(const MapElement& I)		// copy constructor
	:  src(I.src), img(I.img)
	{}
	MapElement()	// 10/10/95 Had to allow this because when a
			// Set<MapElement> is created, Set allocates
			// a certain number of blank MapElements.
	: src(0,0), img()
	{   // assert(0);		No sensible way to initialize src.
	}
       ~MapElement()
	{}
	MapElement& operator=(const MapElement& I) // assignment
	{
		src = I.src;
		img = I.img;
		return *this;
	}
	Boolean operator==(const MapElement& I) const  // Careful: only names compared!
	{  return (src.name()==I.src.name());
	}

   friend ostream& operator << (ostream& out, const MapElement& s);
   friend istream& operator >> (istream&  in,       MapElement& s);

};

ostream& operator << (ostream& out, const MapElement& s)
{	out  << s.src  << " -> " << s.img ;
	return out;
}
istream& operator >> (istream& in, MapElement& s)
{	
	in  >> s.src;
	char c;
	while( in.get(c) )
	{
		if(c=='-') break;
	}
	while( in.get(c) )
	{
		if(c=='>') break;
	}
	LinList<DE> image;
	in >> image;
	s.img = image;
	return in;
}
#endif
