Skip to content

A header-only library containing famous data structures implemented from scratch using C++.

License

Notifications You must be signed in to change notification settings

kazurem/dstruct

Repository files navigation

dstruct

A header-only library containing famous data structures implemented from scratch using C++.

Usage

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()
}

Installation

Option 1: System-wide (or Local Install)

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 build

Option 2: Integration via FetchContent (Recommended)

Add 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)

Usage

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)

Development and Testing

Building the Test Suite

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 && ctest

References

Some useful references:

  1. Conventional Commits: A convention for commit messages.
  2. CMake: Meta build system
  3. EditorConfig: Consistent coding styles for multiple developers working on the same project across various editors and IDEs
  4. gitattributes
  5. Commitizen: For standardized commit messages and automatic changelog updation.
  6. clang-format: Tool to format C++ code automatically.
  7. clang-tidy: A clang-based C++ linter tool.
  8. pre-commit: A framework for managing and maintaining multi-language pre-commit hooks.
  9. Google Test:a specialized library utilized to conduct unit testing in the C++ programming language
  10. Keep a changelog

Acknowledgements

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.

About

A header-only library containing famous data structures implemented from scratch using C++.

Topics

Resources

License

Stars

Watchers

Forks