How saurabh-iitr2020/practice-cpp works
Project Type and Purpose
• This is a monorepo of C++ practice projects: implementations of core data structures (arrays, linked lists, trees, graphs, hash tables, queues, priority queues) and algorithms (merge sort, quick sort, binary search tree operations).
• It uses CMake as the build system and GoogleTest (under lib/googletest) for unit testing.
• It is not a deployed service or full-stack app, but an educational/utility library of independent modules.
File Structure Analysis
• Top‐level:
• CMakeLists.txt – orchestrates discovery and building of each module.
• valgrind.sh – helper script for memory checking.
• lib/googletest – external test framework.
• A directory per module (arrays, binary_search_tree, graphs, hash_table, linked_lists, merge_sort, priority_queue, queue_array, queue_linked_list, quick_sort).
• Each module:
• CMakeLists.txt
• src files (.cc/.h)
• main.cc (example driver)
• tests (for some modules, either built into the same folder or separate tests folder)
• No cross‐dependencies between modules except all link to GoogleTest for their unit tests.
README Insights
• Minimal description: confirms this is day-to-day C++ practice code.
• Warns code quality/bugs might exist.
Components
a. Build System (CMake)
b. Modules (grouped by category):
• Data Structures: arrays/jvector, linked_lists, queue_array, queue_linked_list, priority_queue, hash_table, binary_search_tree, graphs
• Algorithms: merge_sort, quick_sort
c. Test Framework: GoogleTest (external library under lib/googletest)
d. Drivers: each module’s main.cc for demonstration
e. Tools: valgrind.sh
f. Developer Workflow: developer runs CMake → build → runs tests and demo executables → optionally valgrind.sh
Relationships and Data Flows
• CMakeLists.txt (root) ──► invokes module‐level CMakeLists.txt
• Module source files ──► compiled by CMake into:
• Demo executables (from main.cc)
• Test executables (linking module code + GoogleTest)
• Test executables ──► execute unit tests, reporting via GoogleTest
• valgrind.sh ──► runs built executables under Valgrind for memory checks
Architectural Patterns and Principles
• Modular separation: each algorithm/data structure is isolated in its own CMake target
• Single Responsibility: modules only contain code/tests for one concept
• External dependency isolation: GoogleTest lives in lib/googletest and is only linked by test targets
• Build‐time orchestration via hierarchical CMakeLists