Skip to content

WANDEX/algorithms

Repository files navigation

coverage lines    functions branches CI/CD cmake-multi-platform

wndx::algo

Header only C++20 lib of Data Structures Algorithms written mainly for self-education and exploration of C++.

Requirements

Build

$ git clone --recurse-submodules [email protected]:WANDEX/algorithms.git && cd algorithms
$ cmake -E make_directory build
$ cmake -S . -B build
$ cmake --build build

Detailed Instruction

MSVC -- Windows platform using Visual Studio compiler in git-bash shell -- MINGW
NOTE: Always preferred version of CMake is a modern stable release compiled from source!
  • Check project root CMakeLists.txt cmake_minimum_required VERSION.
  • CMake version installed with your Visual Studio may be obsolete.
  • Microsoft also patches CMake versions for their MSVC toolchain.
  • Such patched and/or obsolete versions may be e.g. cmake --version 3.26.0-msvc3 etc.
  • Proper work with patched versions of CMake is not guaranteed and may not be guaranteed!
prepare build environment:
## backup unmodified PATH
$ export PATH0="$PATH"

## add MSVC toolchain dir with cl compiler to the PATH
$ export PATH="$PATH:/c/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64"

## add DrMemory to the PATH
$ export PATH="$PATH:/c/wndx/src/top/DrMemory-Windows-2.6.0/bin64"

## make new build dir
$ bdir="./build/msvc"
$ [ -d "$bdir" ] &&   rm -rf "$bdir"
$ [ -d "$bdir" ] || mkdir -p "$bdir"
compile, test, memcheck:
## cmake configure
$ cmake -S . -B "$bdir" -G "Visual Studio 17 2022" -D WNDX_ALGO_BUILD_TESTS=ON -D WNDX_ALGO_MEMCHECK_ENABLE=ON

## cmake build
$ cmake --build "$bdir"

## execute unit tests
$ ctest --test-dir "$bdir/tests/units/"

## check onto memory leaks executing unit tests via DrMemory
$ cmake --build "$bdir" --target memcheck

Integration

CMakeLists.txt that uses wndx::algo can look like this:

project(project_1337)

include(FetchContent)
FetchContent_Declare(
  wndx_algo
  GIT_REPOSITORY https://github.com/WANDEX/algorithms.git
  GIT_TAG        0.0.3 # latest tag commit hash is preferred
)
FetchContent_MakeAvailable(wndx_algo)

add_executable(project_1337)
target_sources(project_1337 PRIVATE main.cpp)
target_link_libraries(project_1337 PRIVATE wndx_algo::algo)

Tree of Implemented DSA

include/
└── wndx/
    └── algo/
        ├── ds/
        │   ├── BinaryHeapQ.hpp ( BinaryHeapQ.t.cpp )
        │   ├── BITreeRQPU.hpp ( BITreeRQPU.t.cpp )
        │   ├── BSTuptr.hpp ( BSTuptr.t.cpp )
        │   ├── BSTuptrIterator.hpp
        │   ├── BSTuptrNode.hpp
        │   ├── DLLraw.hpp ( DLLraw.t.cpp )
        │   ├── IQueue.hpp
        │   ├── IStack.hpp
        │   ├── ListQueue.hpp ( ListQueue.t.cpp )
        │   ├── ListStack.hpp ( ListStack.t.cpp )
        │   └── UnionFind.hpp ( UnionFind.t.cpp )
        └── sort/
            ├── bubble_sort.hpp ( sort.t.cpp )
            ├── insertion_sort.hpp ( sort.t.cpp )
            ├── merge_sort.hpp ( sort.t.cpp )
            ├── quick_sort.hpp ( sort.t.cpp )
            └── selection_sort.hpp ( sort.t.cpp )

Hall of Fame

DSA implemented in Java, repository contains many useful things: code, tests, slides, references, videos.
Huge respect to William Fiset for the gratuitous dissemination of knowledge. :godmode:

License

MIT

About

[WIP] platform-agnostic C++20 DSA lib

Resources

License

Stars

Watchers

Forks