Skip to content

Conversation

yusuf601
Copy link
Contributor

@yusuf601 yusuf601 commented Sep 24, 2025

refactor: implement allocator on constructor

Deskripsi (Description)

Membuat Allocator pada STL,dengan allocator container dapat mengelola memory sendiri alih2 memakai new dan delete

Perubahan yang diberikan

  1. Membuat Template Allocator
template <typename T,typename Allocator = std::allocator<T>>
  1. rebind allocator
    Allocator hanya mengalokasikan tipe T tetapi pada linked list,Allocatorjuga harus mengalokasikanTdannode(pointer next)`,maka strategi adalah melakukan rebind
        using node_allocator_type = 
        typename std::allocator_traits<Allocator>::template rebind_alloc<Node>;

3.Melakukan Refactor pada semua constructor
refactor semua constructor dan destructor,keberhasilan refactor dilihat dari hasil testing berikut

100% tests passed, 0 tests failed out of 20

Total Test time (real) =   0.03 sec

Checklist

Umum:
  • Saya menambah algoritma terbaru.
  • Saya menambah dokumentasi.
Contributor Requirements (Syarat Kontributor) dan Lain-Lain:
  • Saya telah menambahkan komentar kode yang memberikan penjelasan maksud dari kode yang saya buat.
  • Saya menggunakan bahasa Indonesia untuk memberikan penjelasan dari kode yang saya buat.

Environment

Saya menggunakan (I'm using):

  • OS = Linux
  • g++ = 15.2.1

Link Issues

Issues: # <!-- if don't have a issue,please do not fill this>


License

This Commit License
https://github.com/Build-X-From-Scratch/forward_list_sratch/blob/main/LICENSE

@yusuf601 yusuf601 added this to the Patching Allocator milestone Sep 24, 2025
@yusuf601 yusuf601 requested review from aaaskyyyy and a team September 24, 2025 13:41
@yusuf601 yusuf601 self-assigned this Sep 24, 2025
@yusuf601 yusuf601 merged commit d1dbd45 into Build-X-From-Scratch:main Sep 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant