Aisha Maabreh CSS 342 Winter 2023
Goals: Working with pointers and linked lists
This project implements a Skiplist data structure in C++. A Skiplist is a probabilistic data structure that allows for fast search, insertion, and deletion operations. It is similar to a linked list but with multiple levels, where each level is a subset of the level below it.
- .clang-format: Configuration file for
clang-formatto ensure consistent code formatting. - .clang-tidy: Configuration file for
clang-tidyto enforce coding standards and catch common errors. - .gitignore: Specifies files and directories to be ignored by Git.
- .vscode/: Contains Visual Studio Code configuration files.
- c_cpp_properties.json: Configuration for IntelliSense and compiler paths.
- launch.json: Configuration for debugging.
- settings.json: General settings for the workspace.
- tasks.json: Tasks for building the project.
- check-code-coverage.sh: Script to compile the program with code coverage flags and generate a report.
- create-output.sh: Script to compile, run, and check the program for warnings, formatting issues, and memory leaks.
- main.cpp: Contains the main function and test cases for the Skiplist.
- random.cpp: Implementation of a simple random number generator.
- random.h: Header file for random.cpp.
- README.md: This file.
- runit.sh: Script to compile and run the program.
- sample-output.txt: Sample output of the program.
- skiplist.cpp: Implementation of the Skiplist data structure.
- skiplist.h: Header file for skiplist.cpp.
- DoublyAndCircularDoublyLinkedListsDiagram.jpg: Unrelated diagram of a doubly and a circular doubly linked list.
clang++org++compilerclang-tidyclang-formatvalgrind(optional, for memory leak detection)
To build and run the project, you can use the provided scripts:
-
runit.sh: Compiles and runs the program.
./runit.sh
-
create-output.sh: Compiles, runs, and checks the program for warnings, formatting issues, and memory leaks.
./create-output.sh > output.txt 2>&1
-
check-code-coverage.sh: Compiles the program with code coverage flags and generates a report.
./check-code-coverage.sh
The main.cpp file contains test cases for the Skiplist. These tests cover basic operations, copy constructor, multi-level Skiplist, and removal operations. The tests use the Random::random function to generate random numbers, ensuring consistent results across runs.
The project uses clang-format and clang-tidy to ensure consistent code formatting and catch common errors. The configuration files for these tools are provided in the repository.
The project uses valgrind to detect memory leaks. The create-output.sh script runs the program with valgrind and reports any memory leaks.
The check-code-coverage.sh script compiles the program with code coverage flags and generates a coverage report using llvm-profdata and llvm-cov.