Coder Social home page Coder Social logo

dynamic-contiguous-memory-queue's Introduction

Dynamic Contiguous Memory Queue

Data Structures

(FSC-BCS-370-Mod5)

Output

output

Assignment Context

This project was assigned as an exercise to fundamentally understand how a Dynamic Contiguous Memory Queue functions.

The repository contains files provided by the professor, including incomplete code for the queue methods, and test code to check for the proper functionality of said methods.

The goal of the assignment was to complete the code, create a template version, and pass the tests to prove comprehension of the data structure.

This project was written in C++ using Visual Studio 2019

Features

This is a C++ implementation of a circular queue data structure.

The queues header file is split into two parts, one for a non-templated implementation of the queue, and one for a templated implementation. The non-templated implementation is in the farmingdale namespace and contains a string array of fixed size for storing elements. The templated implementation is also in the farmingdale namespace and contains a dynamic array of the type specified in the template parameter. The header file also includes a definition for the statusCode enum, which is used to indicate the success or failure of various queue operations, and some constants used by the implementation.

Methods

  1. enqueue: add an element to the back of the queue
  2. dequeue: remove an element from the front of the queue
  3. peek: get the element at the front of the queue without removing it
  4. operator==: check if two queues are equal
  5. constructor: default constructor
  6. rule of threes: destructor, copy constructor, copy assignment operator

Tests

The test code contains three test functions: normalTest1(), normalTest2(), and copyCtorTest(). All of them test different aspects of the queue implementation.

normalTest1():

This function tests the implementation of a queue with a large number of elements (100000 elements in this case). It creates an instance of the queue, enqueues 100000 elements, and dequeues all the elements. It also creates an instance of the queue with integer type and performs similar enqueue and dequeue operations. It checks whether the dequeue operation retrieves elements in the correct order or not. Finally, it checks whether the implementation causes any memory leak.

normalTest2():

This function tests the implementation of the queue with various scenarios of enqueue and dequeue operations. It first fills the queue with 16 elements (assuming the initial capacity of the queue is 16). Then, it dequeues 5 elements and enqueues 4 more elements. After that, it enqueues 100000 more elements, causing a reallocation of the queue. Finally, it dequeues all the elements and checks whether the dequeue operation retrieves elements in the correct order or not.

copyCtorTest():

This function tests the implementation of the copy constructor. It creates an instance of the queue, enqueues 100000 elements, and creates two new instances of the queue using the copy constructor. It checks whether the two new instances are equal to the original instance or not. Then, it dequeues all the elements from both the new instances and checks whether they retrieve elements in the correct order or not. In the templated version of the tests, the same tests are performed on a templated version of the queue implementation, one with string type and the other with integer type.

dynamic-contiguous-memory-queue's People

Contributors

alexander-harmaty avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.