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

 
Output of file : MULTIHAS.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 "GPInclude.h"
#include "HashTable.h"

#ifndef MultiHashTable_h
#define MultiHashTable_h

// Interface to Hashtable that create _mht_entry (subclass of link)
// for numbers, strings and pointers and provides hashing algorithms
// For numbers and pointers it is simple division relying on the fact
// that the number of buckets will always be prime. For strings it is
// hashpjw from the Dragon Book.

typedef void (*PFIVV)(int, void*);

class MultiHashTable : public HashTable {
protected:
class _mht_entry : public Link {
protected:
enum EntryType { EntryNumber=1, EntryString, EntryPointer};
union {
int _number;
char* _string;
void* _pointer;
};
EntryType _type;
public:
_mht_entry(int);
_mht_entry(char*);
_mht_entry(void*);
virtual ~_mht_entry();

int type();

int number();
char* string();
void* pointer();

virtual int hash(int);
virtual int compare(Link*);
virtual void inspect();
};

class _mht_list : public HintList {
public:
_mht_list() : HintList() {};
virtual ~_mht_list() { destroy(); };
virtual void mapcar(PFLV f);
};

class _mht_table : public _ht_table {
public:
_mht_table(HintList * t, int _n) : _ht_table(t,_n) {};
virtual ~_mht_table() {};
virtual HintList * operator[](int i);
};

virtual int isIn(_mht_entry * e, int n=0);
public:
MultiHashTable(int size, PFIVV f=0);
MultiHashTable(int size, PFIVV f, int derived);
virtual ~MultiHashTable();

// Remove and isIn return whether or not they succeeded, and the
// reason for failure is the inability to locate the values.

virtual void insert(int);
virtual int remove(int,int n=0);
virtual int isIn(int, int n=0);

virtual void insert(char*);
virtual int remove(char*,int n=0);
virtual int isIn(char*, int n=0);

virtual void insert(void*);
virtual void* remove(void*,int n=0);
virtual int isIn(void*, int n=0);

};

inline
_mht_entry::_mht_entry(int number)
{
_type = EntryNumber;
_number = number;
}

// In the interests of efficiency, do not copy inside ctor. That way,
// creation of temporary entries for comparison works without going
// through the allocator.
inline
_mht_entry::_mht_entry(char* string)
{
_type = EntryString;
_string = string;
}

inline
_mht_entry::_mht_entry(void* pointer)
{
_type = EntryPointer;
_pointer = pointer;
}

inline int
_mht_entry::type()
{
return _type;
}

inline int
_mht_entry::number()
{
return _number;
}

inline char*
_mht_entry::string()
{
return _string;
}

inline void*
_mht_entry::pointer()
{
return _pointer;
}

#endif


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