Category : Recently Uploaded Files
Archive   : HEADZIP.EXE
Filename : CQUEUE.CPP

 
Output of file : CQUEUE.CPP contained in archive : HEADZIP.EXE
//----------------------------------------------------------------------
// 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 + 1) MOD MAX_LENG
// && 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 + 1) MOD MAX_LENG
//..................................................................
{
front = (front + 1) % MAX_LENG;
}


  3 Responses to “Category : Recently Uploaded Files
Archive   : HEADZIP.EXE
Filename : CQUEUE.CPP

  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/