Skip to content

A collection of extra algorithms on top of the std ones

License

Notifications You must be signed in to change notification settings

CoolLibs/algorithms

Repository files navigation

algorithms

Including

To add this library to your project, simply add these two lines to your CMakeLists.txt:

add_subdirectory(path/to/algorithms)
target_link_libraries(${PROJECT_NAME} PRIVATE algorithms::algorithms)

Then include it as:

#include <algorithms/algorithms.hpp>

Documentation

translocate()

Moves an element in a container from its current position to a new one. The order of the other elements is preserved.
It takes two iterators, pointing to the current and new locations:

auto vec = std::vector<int>{0, 1, 2, 3, 4};

algorithms::translocate(
    vec.begin() + 4,
    vec.begin() + 2
);

// vec is now {0, 1, 4, 2, 3}

⚠️ This currently doesn't work for std::list.

Running the tests

Simply use "tests/CMakeLists.txt" to generate a project, then run it.
If you are using VSCode and the CMake extension, this project already contains a .vscode/settings.json that will use the right CMakeLists.txt automatically.

About

A collection of extra algorithms on top of the std ones

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published