head     1.3;
branch   ;
access   ;
symbols  ;
locks    ; strict;
comment  @// @;


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

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

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


desc
@implementation of the IntPointSet iterator container class
@


1.3
log
@Iterators no longer use multiple inheritance.  They now use
IntPointSets (and the hashing that implies).
@
text
@// Emacs: -*- C++ -*-
static char rcsid[] = "$Id: IPSIter.cc,v 1.2 92/07/21 11:25:30 thoth Exp Locker: thoth $";

// 
// $Log:	IPSIter.cc,v $
// Revision 1.2  92/07/21  11:25:30  thoth
// New code to support BlackHoles, WhiteHoles and Yoders
// 
// Revision 1.1  92/07/16  11:56:18  thoth
// Initial revision
// 
// 

#include "IPSIter.h"
#include "BoxyIPSIter.h"
#include "YoderIPSIter.h"

#pragma implementation

class WhiteIter: public BaseIPSIter {
private:
    int	done;
public:
    WhiteIter(const IntPointSet&ps): BaseIPSIter(ps) { done=0; }
    BaseIPSIter *clone_self() { return new WhiteIter(domain); }
    int next(IntPoint& ip) {
	if (done)
	    return 0;
	else {
	    ip = IntPoint();
	    done = 1;
	    return 1;
	}
    }
    void reset() { done=0; }
};

class BlackIter: public BaseIPSIter {
public:
    BlackIter(const IntPointSet&ps): BaseIPSIter(ps) {}
    BaseIPSIter *clone_self() { return new BlackIter(domain); }
    int next(IntPoint& ip) {
	return 0;
    }
    void reset() {}
};

BaseIPSIter * IPSIter::make_iter(const IntPointSet & ips)
{
    switch (ips.type()) {
    case BOXY:
	return new BoxyIPSIter(ips,(BoxyIPS*)ips.ps);
    case YODER:
	return new YoderIPSIter(ips,(YoderIPS*)ips.ps);
    case WHITE:
	return new WhiteIter(ips);
    case BLACK:
	return new BlackIter(ips);
    default:
	// AUGH!!
	abort();
	return 0;
    }
}

IPSIter & IPSIter::operator=(const IntPointSet &x)
{
    delete this->iter;

    this->iter = make_iter(x);

    return *this;
}

IPSIter & IPSIter::operator=(const IPSIter &x)
{
    if (x.iter==this->iter)
	return *this;

    delete this->iter;

    this->iter = x.iter->clone_self();

    return *this;
}
@


1.2
log
@New code to support BlackHoles, WhiteHoles and Yoders
@
text
@d2 1
a2 1
static char rcsid[] = "$Id: IPSIter.cc,v 1.1 92/07/16 11:56:18 thoth Exp Locker: thoth $";
d6 3
d24 2
a25 1
    WhiteIter() { done=0; }
d40 2
a41 1
    BlackIter() {}
d48 1
a48 1
IPSIter:: IPSIter(const IntPointSet & ips)
d52 1
a52 2
	iter = new BoxyIPSIter(*(BoxyIPS*)ips.ps);
	break;
d54 1
a54 2
	iter = new YoderIPSIter(*(YoderIPS*)ips.ps);
	break;
d56 1
a56 2
	iter = new WhiteIter;
	break;
d58 1
a58 2
	iter = new BlackIter;
	break;
d62 1
a62 1
	break;
d64 21
@


1.1
log
@Initial revision
@
text
@d2 1
a2 1
static char rcsid[] = "$Id$";
d5 3
a7 1
// $Log$
d9 1
d13 1
d17 26
d49 9
d60 1
@
