A header-only library containing famous data structures implemented from scratch using C++.
We can use the library's data structures by including the appropriate header files.
#include <dlist.hpp> //importing doubly non circular linked list
int main() {
dstruct::DList<int> list;
list.insert(0, 1); // [1]
list.insert(0, 2); // [2, 1]
list.insert(0, 3); // [3, 2, 1]
list.display()
}You can install the headers and CMake configuration files to a specific directory to use them in multiple projects.
# Clone the repository
git clone https://github.com/yourusername/dstruct.git
cd dstruct
# Configure and install to a local 'dist' folder
cmake -B build -DCMAKE_INSTALL_PREFIX=./dist
cmake --install buildAdd dstruct directly to your project's CMakeLists.txt without downloading it manually:
include(FetchContent)
FetchContent_Declare(
dstruct
GIT_REPOSITORY https://github.com/yourusername/dstruct.git
GIT_TAG main # Or a specific commit/version
)
FetchContent_MakeAvailable(dstruct)
# Link your target
target_link_libraries(your_project_name PRIVATE dstruct::dstruct)If you installed dstruct using Option 1, use find_package in your project's CMakeLists.txt:
find_package(dstruct REQUIRED)
add_executable(MyProject main.cpp)
target_link_libraries(MyProject PRIVATE dstruct::dstruct)dstruct uses GoogleTest for unit testing. Testing is disabled by default to keep builds fast for users.
To build and run tests:
# Enable testing during configuration
cmake -B build -DBUILD_TESTING=ON
# Build the tests
cmake --build build
# Run the tests
cd build && ctestSome useful references:
- Conventional Commits: A convention for commit messages.
- CMake: Meta build system
- EditorConfig: Consistent coding styles for multiple developers working on the same project across various editors and IDEs
- gitattributes
- Commitizen: For standardized commit messages and automatic changelog updation.
- clang-format: Tool to format C++ code automatically.
- clang-tidy: A clang-based C++ linter tool.
- pre-commit: A framework for managing and maintaining multi-language pre-commit hooks.
- Google Test:a specialized library utilized to conduct unit testing in the C++ programming language
- Keep a changelog
Thanks to Nyx-4 for informing me of tools like commitizen and pre-commit-hooks. I modified the CI configuration made by him in this pull request.