Category : Recently Uploaded Files
Archive   : HEADZIP.EXE
Filename : CQUEUE.CPP
// IMPLEMENTATION FILE (cqueue.cpp)
// This module exports an ADT for a queue of at most MAX_LENG-1
// characters.
// Queue representation: a vector (ring buffer) of size MAX_LENG
//----------------------------------------------------------------------
#include "cqueue.h"
// Private members of class:
// int front; // Subscript of queue front - 1
// int rear; // Subscript of queue rear
// char data[MAX_LENG]; // Vector representing the queue
//
// CLASSINV: At all times, at least one element of "data"
// remains unused
CharQueue::CharQueue()
//..................................................................
// Constructor
// POST: front == 0 && rear == 0
//..................................................................
{
front = rear = 0;
}
Boolean CharQueue::IsEmpty() const
//..................................................................
// POST: FCTVAL == (rear == front)
//..................................................................
{
return (rear == front);
}
Boolean CharQueue::IsFull() const
//..................................................................
// POST: FCTVAL == ((rear+1) MOD MAX_LENG == front)
//..................................................................
{
return ((rear+1) % MAX_LENG == front);
}
void CharQueue::Enqueue( /* in */ char newItem )
//..................................................................
// PRE: (rear + 1) MOD MAX_LENG != front
// && Assigned(newItem)
// POST: rear == (rear
// && data[rear] == newItem
//..................................................................
{
rear = (rear + 1) % MAX_LENG;
data[rear] = newItem;
}
char CharQueue::Front() const
//..................................................................
// PRE: rear != front
// POST: FCTVAL == data[(front+1) MOD MAX_LENG]
//..................................................................
{
return data[(front+1) % MAX_LENG];
}
void CharQueue::Dequeue()
//..................................................................
// PRE: rear != front
// POST: front == (front
//..................................................................
{
front = (front + 1) % MAX_LENG;
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
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/