Skip to content

yusuf601/forward_list_sratch

 
 

Repository files navigation

Forward List(Standar Template Library)

C++ Build License

Introductions

This project is a custom implementation of the C++ Standard Template Library (STL) forward_list.
The goal is to understand how the STL container works internally by building it from scratch,
including various member functions, iterators, and algorithms such as sort, merge, and reverse.

Project Structure

.
├── build_failed.sh        // Script for simulating failed build
├── build_testing.sh       // Script for running unit tests
├── CMakeLists.txt         // CMake configuration
├── compile.sh             // Compile main implementation
├── compile_sort.sh        // Compile sorting-related code
├── CONTRIBUTING.md        // Contribution guidelines
├── header/                // Header files
│   └── forward_list.hpp   // Forward list template implementation
├── implementation/        // Implementation details
│   ├── implementation.cpp
│   └── implementation_sort.cpp
├── LICENSE                // License file (MIT)
├── src/                   // Source code prototypes
│   ├── forward_list.cpp
│   ├── merge_list.cpp
│   └── merge_sort.cpp
├── test/                  // Unit tests
│   └── testing.cpp
└── README.md              // Project documentation

Requirements

  • Compiler: g++ 10+/clang++ 12+
  • OS: Linux(recomended),MacOS,Mikocok

Instalation

Clone this repo

git clone https://github.com/Build-X-From-Scratch/forward_list_sratch.git

copy header to your project

cp -r forward_list_sratch/header/forward_list.hpp .

example

#include <iostream>
#include <vector>
#include "../header/forward_list.hpp" //->this header
int main(){
    std::cout << "Testing" << std::endl;
    forward_lists<int>flst = {1,2,3};
    flst.pop_front();
    flst.pop_front();
    flst.print_all(flst.begin(),flst.end()); //3
    return 0;
}   

Compile

if you use g++ then:

g++ -stdc=c++20 example.cpp -o example
./example

if you use clang then:

clang++ -stdc=c++20 example -o example
./example

📌 TODO (Next Features)

Feature Status
insert_after ✅ Done
erase_after ✅ Done
push_front ✅ Todo
pop_front ✅ Todo
reverse ✅ Todo
unique ✅ Todo
Unit Testing ✅ Todo
Sort ✅ Todo
Swap ✅ Todo
emplace_back ✅ Todo
emplace_front ✅ Todo
Assign ✅ Todo
Merge ✅ Todo

Benchmark

benchmark

if you want read details benchmark,you can read in this benchmark result

Develoment

wakatime

License

This project is licensed under the MIT License.
You are free to use, modify, and distribute it with proper attribution.

About

No description, website, or topics provided.

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 97.2%
  • Shell 1.4%
  • CMake 1.3%
  • JavaScript 0.1%