home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Devil's Doorknob BBS Capture (1996-2003)
/
devilsdoorknobbbscapture1996-2003.iso
/
Dloads
/
OTHERUTI
/
MASTER-1.ZIP
/
SOURCE
/
CHAP06
/
CHAP06.LZH
/
SORTED.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1992-07-16
|
2KB
|
85 lines
// SORTED.CPP
// Demonstrates use of the SortedArray class.
// Compile using the Large memory model.
#include <iostream.h>
#include <sortable.h>
#include <sortarry.h>
#include <string.h>
#include <stdlib.h>
class TLogEntry : public Sortable {
public:
TLogEntry(char * NewCallSign,
char * NewContactNum,
char * NewExchange,
int NewMode,
int NewBand,
long NewTime,
long NewDate ) : Sortable () {
strcpy( CallSign, NewCallSign );
strcpy( ContactNum, NewContactNum );
strcpy( Exchange, NewExchange );
Mode = NewMode;
Band = NewBand;
ContactTime = NewTime;
ContactDate = NewDate;
}
virtual hashValueType hashValue() const;
virtual classType isA() const {return __firstUserClass;}
virtual int isEqual( const Object& testObject) const
{ if (stricmp( ((TLogEntry&)testObject).CallSign, CallSign ))
return 0;
else return 1;
}
virtual int isLessThan( const Object& Obj1 ) const
{ if (stricmp( ((TLogEntry&)Obj1).CallSign, CallSign ) > 0)
return 1;
else return 0;
}
virtual char *nameOf() const {return "TLogEntry";}
virtual void printOn( ostream& outputStream) const
{ outputStream << CallSign;}
friend void Display(Object& o, void * );
private:
char CallSign[11];
char ContactNum[11];
char Exchange[35];
int Mode, Band;
long ContactTime;
long ContactDate;
};
hashValueType TLogEntry::hashValue() const
{
return atoi( ContactNum );
}
void Display(Object& o, void * )
{
cout << ((TLogEntry&)o).ContactNum << " " <<
((TLogEntry&) o).CallSign << "\n";
};
void main(void)
{
SortedArray LogBook( 30 );
TLogEntry Contact1( "KF7VY", "0001", "59 EWA", 0, 0, 0, 0 );
TLogEntry Contact2( "N7VPL", "0002", "59 EWA", 0, 0, 0, 0 );
TLogEntry Contact3( "W6ZRJ", "0003", "59 SCV", 0, 0, 0, 0 );
TLogEntry Contact4( "N6IIU", "0004", "59 SF", 0, 0, 0, 0 );
TLogEntry Contact5( "N7LCG", "0005", "59 WWA", 0, 0, 0, 0 );
LogBook.add( Contact1 );
LogBook.add( Contact2 );
LogBook.add( Contact3 );
LogBook.add( Contact4 );
LogBook.add( Contact5 );
cout << "Total number of items in bag = " <<
LogBook.getItemsInContainer() << "\n";
LogBook.forEach( Display, NULL );
LogBook.flush();
}