Skip to content

Commit 7579d7c

Browse files
Merge branch 'TheAlgorithms:master' into master
2 parents 065e8de + 8b1eab2 commit 7579d7c

File tree

123 files changed

+6643
-36205
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

123 files changed

+6643
-36205
lines changed

.github/workflows/gh-pages.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Doxygen CI
22

3-
on:
3+
on:
44
push:
55
branches: [master]
66

@@ -15,7 +15,7 @@ jobs:
1515
run: |
1616
brew install graphviz ninja doxygen
1717
- name: configure
18-
run: cmake -G Ninja -B ./build -S .
18+
run: cmake -G Ninja -Duse_libclang=ON -DCMAKE_CXX_COMPILER=clang++ -B ./build -S .
1919
- name: build
2020
run: cmake --build build -t doc
2121
- name: gh-pages
@@ -28,7 +28,7 @@ jobs:
2828
git config --global user.name "$GITHUB_ACTOR"
2929
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
3030
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
31-
rm -rf d* && rm *.html && rm *.svg && rm *.map && rm *.md5 && rm *.png && rm *.js && rm *.css
31+
rm -rf d* && rm *.html && rm *.svg && rm *.map && rm *.md5 && rm *.png && rm *.js
3232
git add .
3333
cp -rp ./build/html/* . && rm -rf ./build && ls -lah
3434
git add .

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,9 @@ a.out
3434
*.out
3535
*.app
3636

37+
# Cache
38+
.cache/
39+
40+
# Build
3741
build/
3842
git_diff.txt

CMakeLists.txt

Lines changed: 19 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
cmake_minimum_required(VERSION 3.22)
2-
project(Algorithms_in_C++
2+
project(TheAlgorithms/C++
33
LANGUAGES CXX
44
VERSION 1.0.0
55
DESCRIPTION "Set of algorithms implemented in C++."
66
)
77

8-
# set(CMAKE_CXX_CPPLINT "~/anaconda3/bin/cpplint --filter=-legal/copyright --std=c++11")
9-
# find_program(CLANG_FORMAT "clang-format")
10-
11-
set(CMAKE_CXX_STANDARD 11)
8+
# C++ standard
9+
set(CMAKE_CXX_STANDARD 17)
1210
set(CMAKE_CXX_STANDARD_REQUIRED ON)
1311

12+
# Additional warnings and errors
1413
if(MSVC)
15-
# set(CMAKE_CXX_STANDARD 14)
1614
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
17-
endif(MSVC)
15+
add_compile_options(/W4 /permissive-)
16+
else()
17+
add_compile_options(-Wall -Wextra -Wno-register -Werror=vla)
18+
endif()
1819

1920
option(USE_OPENMP "flag to use OpenMP for multithreading" ON)
2021
if(USE_OPENMP)
@@ -38,6 +39,10 @@ add_subdirectory(graphics)
3839
add_subdirectory(probability)
3940
add_subdirectory(backtracking)
4041
add_subdirectory(bit_manipulation)
42+
add_subdirectory(dynamic_programming)
43+
add_subdirectory(greedy_algorithms)
44+
add_subdirectory(range_queries)
45+
add_subdirectory(operations_on_datastructures)
4146
add_subdirectory(data_structures)
4247
add_subdirectory(machine_learning)
4348
add_subdirectory(numerical_methods)
@@ -49,47 +54,30 @@ add_subdirectory(physics)
4954

5055
cmake_policy(SET CMP0054 NEW)
5156
cmake_policy(SET CMP0057 NEW)
57+
5258
find_package(Doxygen OPTIONAL_COMPONENTS dot dia)
53-
if(DOXYGEN_FOUND)
54-
set(DOXYGEN_GENERATE_MAN NO)
55-
set(DOXYGEN_USE_MATHJAX YES)
56-
set(DOXYGEN_GENERATE_HTML YES)
57-
# set(DOXYGEN_HTML_TIMESTAMP YES)
58-
set(DOXYGEN_EXTRACT_STATIC YES)
59-
set(DOXYGEN_INLINE_SOURCES YES)
60-
set(DOXYGEN_CREATE_SUBDIRS YES)
61-
set(DOXYGEN_EXTRACT_PRIVATE YES)
62-
set(DOXYGEN_GENERATE_TREEVIEW YES)
63-
set(DOXYGEN_STRIP_CODE_COMMENTS NO)
64-
set(DOXYGEN_EXT_LINKS_IN_WINDOW YES)
65-
set(DOXYGEN_BUILTIN_STL_SUPPORT YES)
66-
set(DOXYGEN_EXCLUDE_PATTERNS */build/*)
67-
set(DOXYGEN_ENABLE_PREPROCESSING YES)
68-
set(DOXYGEN_CLANG_ASSISTED_PARSING YES)
69-
set(DOXYGEN_FILE_PATTERNS *.cpp *.h *.hpp *.md)
70-
set(DOXYGEN_MATHJAX_EXTENSIONS TeX/AMSmath TeX/AMSsymbols)
71-
set(DOXYGEN_TAGFILES "doc/cppreference-doxygen-web.tag.xml=http://en.cppreference.com/w/")
59+
if(DOXYGEN_FOUND)
7260
if(MSVC)
7361
set(DOXYGEN_CPP_CLI_SUPPORT YES)
7462
endif()
75-
set(DOXYGEN_MATHJAX_RELPATH "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/MathJax.js?config=TeX-MML-AM_CHTML")
63+
7664
if(Doxygen_dot_FOUND)
7765
set(DOXYGEN_HAVE_DOT YES)
78-
set(DOXYGEN_CALL_GRAPH YES)
79-
set(DOXYGEN_INTERACTIVE_SVG YES)
80-
set(DOXYGEN_DOT_IMAGE_FORMAT "svg")
8166
endif()
67+
8268
if(OPENMP_FOUND)
8369
set(DOXYGEN_PREDEFINED "_OPENMP=1")
8470
endif()
71+
8572
if(GLUT_FOUND)
8673
set(DOXYGEN_PREDEFINED ${DOXYGEN_PREDEFINED} "GLUT_FOUND=1")
8774
endif()
8875

8976
doxygen_add_docs(
9077
doc
91-
${PROJECT_SOURCE_DIR}
78+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
9279
COMMENT "Generate documentation"
80+
CONFIG_FILE ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile
9381
)
9482
endif()
9583

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This repository is a collection of open-source implementation of a variety of al
2222
* Well documented source code with detailed explanations provide a valuable resource for educators and students alike.
2323
* Each source code is atomic using [STL classes](https://en.wikipedia.org/wiki/Standard_Template_Library) and _no external libraries_ are required for their compilation and execution. Thus, the fundamentals of the algorithms can be studied in much depth.
2424
* Source codes are [compiled and tested](https://github.com/TheAlgorithms/C-Plus-Plus/actions?query=workflow%3A%22Awesome+CI+Workflow%22) for every commit on the latest versions of three major operating systems viz., Windows, MacOS, and Ubuntu (Linux) using MSVC 19 2022, AppleClang 14.0.0, and GNU 11.3.0 respectively.
25-
* Strict adherence to [C++11](https://en.wikipedia.org/wiki/C%2B%2B11) standard ensures portability of code to embedded systems as well like ESP32, ARM Cortex, etc. with little to no changes.
25+
* Strict adherence to [C++17](https://en.wikipedia.org/wiki/C%2B%2B17) standard ensures portability of code to embedded systems as well like [ESP32](https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/cplusplus.html#c-language-standard), [ARM Cortex](https://developer.arm.com/documentation/101458/2404/Standards-support/Supported-C-C---standards-in-Arm-C-C---Compiler), etc. with little to no changes.
2626
* Self-checks within programs ensure correct implementations with confidence.
2727
* Modular implementations and OpenSource licensing enable the functions to be utilized conveniently in other applications.
2828

backtracking/subarray_sum.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include <cassert> /// for assert
17+
#include <cstdint>
1718
#include <iostream> /// for IO operations
1819
#include <unordered_map> /// for unordered_map
1920
#include <vector> /// for std::vector

backtracking/subset_sum.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212
#include <cassert> /// for assert
13+
#include <cstdint>
1314
#include <iostream> /// for IO operations
1415
#include <vector> /// for std::vector
1516

backtracking/wildcard_matching.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
#include <cassert> /// for assert
15+
#include <cstdint>
1516
#include <iostream> /// for IO operations
1617
#include <vector> /// for std::vector
1718

bit_manipulation/count_bits_flip.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
* @author [Yash Raj Singh](https://github.com/yashrajyash)
2121
*/
2222
#include <cassert> /// for assert
23+
#include <cstdint>
2324
#include <iostream> /// for IO operations
2425
/**
2526
* @namespace bit_manipulation

bit_manipulation/count_of_set_bits.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @author [Prashant Thakur](https://github.com/prashant-th18)
1717
*/
1818
#include <cassert> /// for assert
19+
#include <cstdint>
1920
#include <iostream> /// for IO operations
2021
/**
2122
* @namespace bit_manipulation

bit_manipulation/count_of_trailing_ciphers_in_factorial_n.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
*/
1919

2020
#include <cassert> /// for assert
21+
#include <cstdint>
2122
#include <iostream> /// for IO operations
2223

2324
/**

0 commit comments

Comments
 (0)