Skip to content

Conversation

yusuf601
Copy link
Contributor

feat: implement method swap

Deskripsi (Description)

Menambahkan method swap,method swap dipakai ketika ingin menukar element pada satu list ke list lain

Perubahan yang diberikan

  1. Swap
void swap(forward_lists& others)noexcept{
            if(this == &others){//jika this sama dengan object lain
                return;
            }
            //swap head;
            Node* tempHead = head;
            head = others.head;
            others.head = tempHead; 
            //swap tail
            Node* tempTail = tail;
            tail = others.tail;
            others.tail = tempTail;
            //swap size
            int tempSize = size;
            size = others.size;
            others.size = tempSize;
        }

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 self-assigned this Sep 23, 2025
@yusuf601 yusuf601 merged commit dbbc9a1 into Build-X-From-Scratch:main Sep 23, 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