Category : Alternate Operating Systems - Quarterdeck DesqView, CP/M, etc
Archive   : PCCAPP.ZIP
Filename : LINKITER.H

 
Output of file : LINKITER.H contained in archive : PCCAPP.ZIP
/*
* This file is part of the Choices Operating System
* Developed by: The TAPESTRY Parallel Computing Laboratory
* University of Illinois at Urbana-Champaign
* Department of Computer Science
* 1304 W. Springfield Ave.
* Urbana, IL 61801
*
* Copyright (c) 1987, 1988, 1989 The University of Illinois Board of Trustees.
* All Rights Reserved.
* CONFIDENTIAL INFORMATION. Distribution restricted under license agreement.
*
* Author: See-Mong Tan ([email protected])
* Project Manager and Principal Investigator: Roy Campbell ([email protected])
*
* Funded by: NSF TAPESTRY Grant No. 1-5-30035, NASA ICLASS Grant
* No. 1-5-25469 and No. NSG1471 and AT&T Metronet Grant No. 1-5-37411.
*/
/*
* LinkIterator.h: Iterator over linked lists
*
* $Header: /tmp_mnt/Nodes/babym/sane.6/Includes/Libraries/GeneralPurpose/RCS/LinkIterator.h,v 1.0 91/09/12 14:53:21 sane Exp Locker: sane $
*/

#include "Assert.h"
#include "Link.h"

#ifndef LinkIterator_h
#define LinkIterator_h

class SLink;
class LinkVirtualiser;

// Iterate over Links. Useful for SLinks and NVLinks

class SLinkIterator {
protected:
SLink * initialSLink;
SLink * currentSLink;

virtual int atStart();
virtual void setStart(SLink * newInitial);
virtual int atEnd();
virtual int isEmpty();

public:
SLinkIterator( SLink * s=0 );
~SLinkIterator();

void rewind();
void reset( SLink * newInitial=0 );
SLink * next();
SLink * current();

// LinkVirtualiser to redefine deleteSlink
void destroy(LinkVirtualiser * v);
};

// The start, empty and end functions are meant for a circular list

inline int
SLinkIterator::atStart()
{
return initialSLink != 0 && currentSLink == 0;
}

inline void
SLinkIterator::setStart( SLink * newInitial )
{
initialSLink = newInitial;
currentSLink = 0;
}

inline int
SLinkIterator::atEnd()
{
return initialSLink != 0 && currentSLink == initialSLink;
}

inline int
SLinkIterator::isEmpty()
{
if ( initialSLink == 0 ) {
Assert( currentSLink == 0 );
return 1;
}
else
return 0;
}

inline
SLinkIterator::SLinkIterator( SLink * link )
{
setStart(link);
}

inline
SLinkIterator::~SLinkIterator()
{
}

inline void
SLinkIterator::rewind()
{
currentSLink = 0;
}

inline void
SLinkIterator::reset( SLink * newInitial )
{
setStart( newInitial );
}

// Used for Links. Same as SLinkIterator in iteration functions, since
// iteration depends on single links only. A potential double link
// iterator could have interesting capabilities such as reversals etc.
// I am not sure either that this is useful or necessary. At any rate,
// I do not have any use for such a beast.

class LinkIterator : public SLinkIterator {
public:
LinkIterator( Link * link = 0 );
Link * next();
Link * current();

// No need for virtualisers anymore
void destroy();
};

inline
LinkIterator::LinkIterator( Link * link )
: SLinkIterator( link )
{
}

inline Link *
LinkIterator::next()
{
return (Link *)SLinkIterator::next();
}

inline Link *
LinkIterator::current()
{
return (Link *)SLinkIterator::current();
}

#endif LinkIterator_h


  3 Responses to “Category : Alternate Operating Systems - Quarterdeck DesqView, CP/M, etc
Archive   : PCCAPP.ZIP
Filename : LINKITER.H

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/