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

 
Output of file : LIGHTLIS.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: Aamod Sane ([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.
*/

#include "Assert.h"
#include "List.h"

#ifndef LightList_h
#define LightList_h

// LightList and SLinks will be tested by LightLists.cc in
// Applications/UNIXGP.

// LightList is a list class that will not have the vtable pointer.
// Light is used throughout as a prefix to indicate this.

class LightList;

// Virtualiser provides virtual functions without the vtable. It is
// intended mainly to provide virtual functions for components, in
// this case SLinks. For some class functions, it can also be used.
// But in most cases, this leads to extremely confusing code. The add
// and remove functions below are an example of reasonable
// application of the virtualiser. In general, I have avoided using
// the virtualiser to make virtual functions for the class itself.

// Intended to be used when a number of lists are needed and the
// expense of a vtable pointer per list is too much.

typedef void (*PFSV) (SLink *);

class LightListVirtualiser : public LinkVirtualiser {
public:
virtual void add( LightList * l,
SLink * newEntry, SLink * oldEntry, int head = 0 );
virtual SLink * remove( LightList * l,
SLink * oldEntry, int nth=0);
};

// LightList and List will be very similiar, except for the
// virtualiser parameter. Perhaps it is possible to reuse the code.
// But non virtual function code is ugly.

class LightList {
protected:
SLink * _tail;
SLink * head();
SLink * nthElem(int n); // Elements numbered from 0
// sublist inclusive from start to end
int sublist( int start, int end, SLink*& a, SLink*& b );
public:
LightList();
LightList(SLink * l);
~LightList();

// In some cases, access to actual list may be required.
// But avoid using this unless absolutely essential
SLink * theLink();

SLink * find( SLink * e, LightListVirtualiser * v );
SLink * find( SLink * e, int nth, LightListVirtualiser * v );

// oldEntry must be a pointer to an existing entry
void add( SLink * newEntry, SLink * oldEntry, int head = 0 );
void addFirst( SLink * newEntry, LightListVirtualiser * v );
void addLast( SLink * newEntry, LightListVirtualiser * v );
SLink * remove( SLink * e, int nth, LightListVirtualiser * v);
SLink * removeFirst( LightListVirtualiser * v);
SLink * removeLast( LightListVirtualiser * v);

void destroy(LightListVirtualiser * v);
void inspect(LightListVirtualiser * v);
void mapcar(PFSV f);
};

inline
LightList::LightList()
{
_tail = 0;
}

inline
LightList::LightList( SLink * l )
{
_tail = l;
}

inline
LightList::~LightList()
{
}

inline SLink *
LightList::head()
{
return _tail ? _tail->next() : 0;
}

inline void
LightList::addFirst( SLink * newEntry, LightListVirtualiser * v )
{
v->add( this, newEntry, _tail, 1 );
}

inline void
LightList::addLast( SLink * newEntry, LightListVirtualiser * v )
{
v->add( this, newEntry, _tail );
}

inline SLink *
LightList::removeFirst(LightListVirtualiser * v)
{
return v->remove( this, _tail->next() );
}

inline SLink *
LightList::removeLast(LightListVirtualiser * v)
{
return v->remove( this, _tail );
}

#endif


  3 Responses to “Category : Alternate Operating Systems - Quarterdeck DesqView, CP/M, etc
Archive   : PCCAPP.ZIP
Filename : LIGHTLIS.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/