forward_list
build forward list stl from sratch
Loading...
Searching...
No Matches
forward_lists< T, Allocator > Class Template Reference

#include <forward_list.hpp>

Classes

struct  Node
class  Iterator

Public Member Functions

 forward_lists ()
 forward_lists (const Allocator &a)
template<typename It>
requires my_input_iterator<It>
 forward_lists (It begin, It end)
 constructor range,adalah constructor yang menginialisasi nilai dari sebuah container dengan element dari suatu rentang yang di tentukan oleh 2 iterator awal(first) dan akhir(last)
 forward_lists (std::initializer_list< T > arr)
 initializer list constructor
 forward_lists (const forward_lists &others)
forward_listsoperator= (const forward_lists &others)
 forward_lists (forward_lists &&others) noexcept
 move constructor dipakai ketika ingin memindahkan node pada list a ke list b
forward_listsoperator= (forward_lists &&others) noexcept
 move assignment constructor
 ~forward_lists ()
 destructor
Iterator before_begin ()
 iterator yang menunjuk dummy node yaitu head
Iterator begin ()
 iterator yang menunjuk node pada element pertama pada list
Iterator end ()
 iterator yang menunjuk pointer setelah node terakhir(tail)
Iterator cbegin () const
Iterator cend () const
Iterator cbefore_begin () const
front ()
 method getter yang mengembalikan nilai node pada pos front
int get_size ()
 method getter yang mengembalilkan jumlah element saat ini
bool is_empty ()
 method getter yang mengembalilkan true jika list empty,sebalik false jika tidak kosong
std::size_t max_size () const noexcept
 mengembalikan jumlah maksimum yang dapat di tampung list
back () const noexcept
Allocator get_allocator () const noexcept
bool check_cycle () const noexcept
get_middle () const noexcept
void push_front (T &&data)
 method untuk insertion val pada pos front
void push_front (const T &data)
void pop_front ()
 method untuk deletion val pada pos front
void push_back (const T &value)
 adalah method untuk melakukan insertion dari posisi belakang(tail)
void push_back (T &&value)
void pop_back ()
 pop_back adalah method untuk deletion node di posisi tail
void insert_after (Iterator iter_position, T &&val)
 Menyisipkan elemen setelah posisi iterator tertentu.
void insert_after (Iterator iter_position, const T &val)
void insert_after (Iterator Iterator_position, int n, T &&val)
void insert_after (Iterator Iterator_position, int n, const T &val)
template<std::input_iterator It>
requires (!std::same_as<It,Iterator>)
void insert_after (Iterator iter_position, It itr1, It itr2)
void insert_after (const Iterator iter_position, Iterator listBegin, const Iterator listEnd)
void erase_after (const Iterator iter_position)
void erase_after (const Iterator pos_begin, const Iterator pos_end)
void reverse ()
void assign (std::size_t n, const T &value)
 Method Assign Assign dipakai untuk mereplace list saat ini dengan list baru overload method assign assign(n,value) ->insert value sebanyak n kali assign(initializer_list<T>)->replace value pada initializer list ke list saat ini assign(iterator begin,iterator end) ->replace mulai dari iterator begin sampai sebelum iterator end.
void assign (std::size_t n, T &&value)
void assign (std::initializer_list< T > arr)
template<typename It>
requires my_input_iterator<It>
void assign (It itr1, It itr2)
void splice_after (const Iterator pos, forward_lists &others, const Iterator It)
 slice after method untuk memindahkan node dari satu list ke list lain tanpa menyalin data,tetapi move node pointer
void splice_after (const Iterator pos, forward_lists &&others, const Iterator It)
void splice_after (const Iterator pos, forward_lists &others)
void splice_after (const Iterator pos, forward_lists &&others)
void splice_after (const Iterator pos, forward_lists &others, const Iterator first, const Iterator last)
void splice_after (const Iterator pos, forward_lists &&others, const Iterator first, const Iterator last)
void swap (forward_lists &others) noexcept
void swap (forward_lists &&others) noexcept
void sort ()
template<typename Compare = std::less<T>>
void sort (Compare comp=Compare{})
void merge (forward_lists &others)
void merge (forward_lists &&others)
template<typename compare = std::less<T>>
void merge (forward_lists &others, compare comp=compare{})
template<typename compare = std::less<T>>
void merge (forward_lists &&others, compare comp=compare{})
void merge_sort (forward_lists &others)
void merge_sort (forward_lists &&others)
void resize (std::size_t count)
 resize adalah method untuk mengubah ukuran sebuah list
void resize (std::size_t count, const T &value)
void uniqe_all ()
void uniqe ()
template<std::ranges::input_range R>
void assign_range (R &&rg)
void assign_range (std::initializer_list< T > arr)
void remove (const T &value)
 overload remove untuk menghapus node dengan nilai sama dengan parameter value
void remove (const std::size_t pos)
 method overload remove,untuk menghapus node pada posisi pos
std::size_t remove_count (const T &value)
template<class UnaryPred>
requires (std::predicate<UnaryPred&, const T&>)
void remove_if (UnaryPred p)
template<class UnaryPred>
requires (std::predicate<UnaryPred&,const T&>)
std::size_t remove_if_count (UnaryPred p)
void print_all (Iterator begin, Iterator end)
 method untuk print semua node list
template<std::ranges::input_range R>
void insert_range_after (const Iterator &pos, R &&r)
 method untuk menghapus semua node pada head berguna pada destructor
template<std::ranges::input_range R>
void prepend_range (R &&r)
template<class ... Args>
void emplace_front (Args &&... args)
template<class ... Args>
void emplace_after (Iterator pos, Args &&... args)
template<class... Args>
void emplace_back (Args &&... args)
void clear ()

Private Types

using node_allocator_type
using node_traits = std::allocator_traits<node_allocator_type>

Private Member Functions

Node_create_node (const T &value)
 Allocator explanation Allocator adalah abstraksi cara mengelola memory pada container alih2 melakukan new dan delete,STL memakai allocator yaitu semacam policy class yang akan menentukan: 1.bagaimana alokasi memory dilakukan(allocate) 2.bagaimana membangun object di memori(construct) 3.bagaimana menghancurkan object(destroy) 4.bagaimana membebaskan memory(deallocate).
void _destroy_node (Node *n) noexcept
Nodemerge (Node *left, Node *right)
template<typename compare = std::less<T>>
Nodemerge (Node *left, Node *right, compare comp)
NodegetMiddle (Node *head)
Nodehelper (Node *head)
template<typename compare>
Nodehelper (Node *head, compare comp)

Private Attributes

node_allocator_type alloc
Nodehead = nullptr
Nodetail
int size

Member Typedef Documentation

◆ node_allocator_type

template<typename T, typename Allocator = std::allocator<T>>
using forward_lists< T, Allocator >::node_allocator_type
private
Initial value:
typename std::allocator_traits<Allocator>::template rebind_alloc<Node>

◆ node_traits

template<typename T, typename Allocator = std::allocator<T>>
using forward_lists< T, Allocator >::node_traits = std::allocator_traits<node_allocator_type>
private

Constructor & Destructor Documentation

◆ forward_lists() [1/6]

template<typename T, typename Allocator = std::allocator<T>>
forward_lists< T, Allocator >::forward_lists ( )
inlineexplicit

◆ forward_lists() [2/6]

template<typename T, typename Allocator = std::allocator<T>>
forward_lists< T, Allocator >::forward_lists ( const Allocator & a)
inline

◆ forward_lists() [3/6]

template<typename T, typename Allocator = std::allocator<T>>
template<typename It>
requires my_input_iterator<It>
forward_lists< T, Allocator >::forward_lists ( It begin,
It end )
inline

constructor range,adalah constructor yang menginialisasi nilai dari sebuah container dengan element dari suatu rentang yang di tentukan oleh 2 iterator awal(first) dan akhir(last)

time complexity o(n), dan space complexity O(n)

◆ forward_lists() [4/6]

template<typename T, typename Allocator = std::allocator<T>>
forward_lists< T, Allocator >::forward_lists ( std::initializer_list< T > arr)
inline

initializer list constructor

time complexity O(n),Space Complexity O(n)

◆ forward_lists() [5/6]

template<typename T, typename Allocator = std::allocator<T>>
forward_lists< T, Allocator >::forward_lists ( const forward_lists< T, Allocator > & others)
inline

◆ forward_lists() [6/6]

template<typename T, typename Allocator = std::allocator<T>>
forward_lists< T, Allocator >::forward_lists ( forward_lists< T, Allocator > && others)
inlinenoexcept

move constructor dipakai ketika ingin memindahkan node pada list a ke list b

others.head dipakai untuk menghindari double delete ketika others keluar dari scope function maka destructor dipanggil karena head = others.head maka head == nullptr,akan mengakibatkan undefined behavior

◆ ~forward_lists()

template<typename T, typename Allocator = std::allocator<T>>
forward_lists< T, Allocator >::~forward_lists ( )
inline

destructor

  • panggil method clear head harus tetap menunjuk dummy node

Member Function Documentation

◆ _create_node()

template<typename T, typename Allocator = std::allocator<T>>
Node * forward_lists< T, Allocator >::_create_node ( const T & value)
inlineprivate

Allocator explanation Allocator adalah abstraksi cara mengelola memory pada container alih2 melakukan new dan delete,STL memakai allocator yaitu semacam policy class yang akan menentukan: 1.bagaimana alokasi memory dilakukan(allocate) 2.bagaimana membangun object di memori(construct) 3.bagaimana menghancurkan object(destroy) 4.bagaimana membebaskan memory(deallocate).

policy class Policy class adalah konsep desain di C++ di mana sebuah class tidak menentukan perilaku sendiri, tapi “mendelegasikan” perilaku tertentu ke class lain

◆ _destroy_node()

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::_destroy_node ( Node * n)
inlineprivatenoexcept

◆ assign() [1/4]

template<typename T, typename Allocator = std::allocator<T>>
template<typename It>
requires my_input_iterator<It>
void forward_lists< T, Allocator >::assign ( It itr1,
It itr2 )
inline

◆ assign() [2/4]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::assign ( std::initializer_list< T > arr)
inline

◆ assign() [3/4]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::assign ( std::size_t n,
const T & value )
inline

Method Assign Assign dipakai untuk mereplace list saat ini dengan list baru overload method assign assign(n,value) ->insert value sebanyak n kali assign(initializer_list<T>)->replace value pada initializer list ke list saat ini assign(iterator begin,iterator end) ->replace mulai dari iterator begin sampai sebelum iterator end.

Time complexity O(n),Space Complexity O(n)

◆ assign() [4/4]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::assign ( std::size_t n,
T && value )
inline

◆ assign_range() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
template<std::ranges::input_range R>
void forward_lists< T, Allocator >::assign_range ( R && rg)
inline

◆ assign_range() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::assign_range ( std::initializer_list< T > arr)
inline

◆ back()

template<typename T, typename Allocator = std::allocator<T>>
T forward_lists< T, Allocator >::back ( ) const
inlinenoexcept

◆ before_begin()

template<typename T, typename Allocator = std::allocator<T>>
Iterator forward_lists< T, Allocator >::before_begin ( )
inline

iterator yang menunjuk dummy node yaitu head

◆ begin()

template<typename T, typename Allocator = std::allocator<T>>
Iterator forward_lists< T, Allocator >::begin ( )
inline

iterator yang menunjuk node pada element pertama pada list

◆ cbefore_begin()

template<typename T, typename Allocator = std::allocator<T>>
Iterator forward_lists< T, Allocator >::cbefore_begin ( ) const
inline

◆ cbegin()

template<typename T, typename Allocator = std::allocator<T>>
Iterator forward_lists< T, Allocator >::cbegin ( ) const
inline

◆ cend()

template<typename T, typename Allocator = std::allocator<T>>
Iterator forward_lists< T, Allocator >::cend ( ) const
inline

◆ check_cycle()

template<typename T, typename Allocator = std::allocator<T>>
bool forward_lists< T, Allocator >::check_cycle ( ) const
inlinenoexcept

◆ clear()

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::clear ( )
inline

◆ emplace_after()

template<typename T, typename Allocator = std::allocator<T>>
template<class ... Args>
void forward_lists< T, Allocator >::emplace_after ( Iterator pos,
Args &&... args )
inline

◆ emplace_back()

template<typename T, typename Allocator = std::allocator<T>>
template<class... Args>
void forward_lists< T, Allocator >::emplace_back ( Args &&... args)
inline

◆ emplace_front()

template<typename T, typename Allocator = std::allocator<T>>
template<class ... Args>
void forward_lists< T, Allocator >::emplace_front ( Args &&... args)
inline

◆ end()

template<typename T, typename Allocator = std::allocator<T>>
Iterator forward_lists< T, Allocator >::end ( )
inline

iterator yang menunjuk pointer setelah node terakhir(tail)

◆ erase_after() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::erase_after ( const Iterator iter_position)
inline

◆ erase_after() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::erase_after ( const Iterator pos_begin,
const Iterator pos_end )
inline

◆ front()

template<typename T, typename Allocator = std::allocator<T>>
T forward_lists< T, Allocator >::front ( )
inline

method getter yang mengembalikan nilai node pada pos front

time complexity O(1)

◆ get_allocator()

template<typename T, typename Allocator = std::allocator<T>>
Allocator forward_lists< T, Allocator >::get_allocator ( ) const
inlinenoexcept

◆ get_middle()

template<typename T, typename Allocator = std::allocator<T>>
T forward_lists< T, Allocator >::get_middle ( ) const
inlinenoexcept

◆ get_size()

template<typename T, typename Allocator = std::allocator<T>>
int forward_lists< T, Allocator >::get_size ( )
inline

method getter yang mengembalilkan jumlah element saat ini

time complexity O(1)

◆ getMiddle()

template<typename T, typename Allocator = std::allocator<T>>
Node * forward_lists< T, Allocator >::getMiddle ( Node * head)
inlineprivate

◆ helper() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
Node * forward_lists< T, Allocator >::helper ( Node * head)
inlineprivate

◆ helper() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
template<typename compare>
Node * forward_lists< T, Allocator >::helper ( Node * head,
compare comp )
inlineprivate

◆ insert_after() [1/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::insert_after ( const Iterator iter_position,
Iterator listBegin,
const Iterator listEnd )
inline

◆ insert_after() [2/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::insert_after ( Iterator iter_position,
const T & val )
inline

◆ insert_after() [3/6]

template<typename T, typename Allocator = std::allocator<T>>
template<std::input_iterator It>
requires (!std::same_as<It,Iterator>)
void forward_lists< T, Allocator >::insert_after ( Iterator iter_position,
It itr1,
It itr2 )
inline

◆ insert_after() [4/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::insert_after ( Iterator iter_position,
T && val )
inline

Menyisipkan elemen setelah posisi iterator tertentu.

Method ini memiliki beberapa bentuk (overload) untuk menyesuaikan kebutuhan:

  1. insert_after(iterator pos, const T& value)
    Menyisipkan satu elemen setelah posisi pos.
  2. insert_after(iterator pos, size_type n, const T& value)
    Menyisipkan n elemen dengan nilai value setelah posisi pos.
  3. insert_after(iterator pos, InputIterator first, InputIterator last)
    Menyisipkan elemen dari rentang [first, last) setelah posisi pos.
  4. insert_after(iterator pos, std::initializer_list<T> ilist)
    Menyisipkan seluruh elemen dari ilist setelah posisi pos.

Overload insert_after(iterator pos, const T& value)

Method ini biasanya membutuhkan 2 overload function agar dapat bekerja optimal:

  1. Overload dengan parameter const reference (const T&):
    • Digunakan ketika argumen yang diberikan adalah lvalue.
    • Objek tidak dipindahkan, tetapi disalin (copy).
    • Efisien karena tidak membuat salinan tambahan saat menerima lvalue.
    • Keterbatasan: tidak bisa langsung menerima rvalue.
  2. Overload dengan parameter rvalue reference (T&&) / forwarding reference:
    • Digunakan ketika argumen adalah rvalue atau ketika kita ingin memanfaatkan move semantics.
    • Bisa juga menerima lvalue, karena forwarding reference tunduk pada reference collapsing rules.
    • Harus dipanggil dengan std::forward<T>(val) agar semantik lvalue/rvalue tetap terjaga.

Catatan penting mengenai forwarding reference:

  • Jika argumen adalah lvalue, maka T akan terdeduksi sebagai T&, dan parameter T&& akan menjadi T& && → dikecilkan (collapse) menjadi T&.
  • Jika argumen adalah rvalue, maka T akan terdeduksi sebagai T, dan parameter T&& benar-benar menjadi rvalue reference.

Dengan dua overload ini:

  • insert_after(pos, x) → memanggil versi const T& (copy dari lvalue).
  • insert_after(pos, std::move(x)) atau insert_after(pos, T("...")) → memanggil versi T&& (move dari rvalue).

◆ insert_after() [5/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::insert_after ( Iterator Iterator_position,
int n,
const T & val )
inline

◆ insert_after() [6/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::insert_after ( Iterator Iterator_position,
int n,
T && val )
inline

◆ insert_range_after()

template<typename T, typename Allocator = std::allocator<T>>
template<std::ranges::input_range R>
void forward_lists< T, Allocator >::insert_range_after ( const Iterator & pos,
R && r )
inline

method untuk menghapus semua node pada head berguna pada destructor

time complexity O(n),Space Complexity O(n)

◆ is_empty()

template<typename T, typename Allocator = std::allocator<T>>
bool forward_lists< T, Allocator >::is_empty ( )
inline

method getter yang mengembalilkan true jika list empty,sebalik false jika tidak kosong

time complexity O(1)

◆ max_size()

template<typename T, typename Allocator = std::allocator<T>>
std::size_t forward_lists< T, Allocator >::max_size ( ) const
inlinenoexcept

mengembalikan jumlah maksimum yang dapat di tampung list

konsep adalah maksimum byte element yang dapat ditampung type data dibagi oleh jumlah memory untuk 1 node satu node terdiri dari:

  • data (misal int ) ->4 byte
  • pointer ke node berikut nya(Node) -> 8 byte pada arsitektur 64 byte jadi perhitungannya:
    std::numeric_limits<size_t>::max() / sizeof(Node)
    Definition forward_list.hpp:46
    Time complexity O(1),Space Complexity O(1)

◆ merge() [1/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::merge ( forward_lists< T, Allocator > && others)
inline

◆ merge() [2/6]

template<typename T, typename Allocator = std::allocator<T>>
template<typename compare = std::less<T>>
void forward_lists< T, Allocator >::merge ( forward_lists< T, Allocator > && others,
compare comp = compare{} )
inline

◆ merge() [3/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::merge ( forward_lists< T, Allocator > & others)
inline

◆ merge() [4/6]

template<typename T, typename Allocator = std::allocator<T>>
template<typename compare = std::less<T>>
void forward_lists< T, Allocator >::merge ( forward_lists< T, Allocator > & others,
compare comp = compare{} )
inline

◆ merge() [5/6]

template<typename T, typename Allocator = std::allocator<T>>
Node * forward_lists< T, Allocator >::merge ( Node * left,
Node * right )
inlineprivate

◆ merge() [6/6]

template<typename T, typename Allocator = std::allocator<T>>
template<typename compare = std::less<T>>
Node * forward_lists< T, Allocator >::merge ( Node * left,
Node * right,
compare comp )
inlineprivate

◆ merge_sort() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::merge_sort ( forward_lists< T, Allocator > && others)
inline

◆ merge_sort() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::merge_sort ( forward_lists< T, Allocator > & others)
inline

◆ operator=() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
forward_lists & forward_lists< T, Allocator >::operator= ( const forward_lists< T, Allocator > & others)
inline

◆ operator=() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
forward_lists & forward_lists< T, Allocator >::operator= ( forward_lists< T, Allocator > && others)
inlinenoexcept

move assignment constructor

◆ pop_back()

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::pop_back ( )
inline

pop_back adalah method untuk deletion node di posisi tail

time complexity O(n),Space complexity O(1)

◆ pop_front()

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::pop_front ( )
inline

method untuk deletion val pada pos front

Time complexity O(1),Space Complexity O(1)

◆ prepend_range()

template<typename T, typename Allocator = std::allocator<T>>
template<std::ranges::input_range R>
void forward_lists< T, Allocator >::prepend_range ( R && r)
inline

◆ print_all()

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::print_all ( Iterator begin,
Iterator end )
inline

method untuk print semua node list

Time complexity O(n),Space Complexity O(n)

◆ push_back() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::push_back ( const T & value)
inline

adalah method untuk melakukan insertion dari posisi belakang(tail)

time complexity O(1)

◆ push_back() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::push_back ( T && value)
inline

◆ push_front() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::push_front ( const T & data)
inline

◆ push_front() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::push_front ( T && data)
inline

method untuk insertion val pada pos front

Time complexity O(1),Space Complexity O(1)

◆ remove() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::remove ( const std::size_t pos)
inline

method overload remove,untuk menghapus node pada posisi pos

Parameters
posposisi node yang ingin dihapus

Time complexity best case: O(1) jika pos di head->next(node pertama) average case: O(n) jika pos ditengah list worst case: O(n) jika pos diakhir list(tail)

◆ remove() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::remove ( const T & value)
inline

overload remove untuk menghapus node dengan nilai sama dengan parameter value

Parameters
valuenilai node yang ingin dihapus pada list

Time complexity Best case: O(1),jika hanya node dan berada di pos head->next average case: O(n) worst case: O(n),tetapi menghapus semua node pada list

◆ remove_count()

template<typename T, typename Allocator = std::allocator<T>>
std::size_t forward_lists< T, Allocator >::remove_count ( const T & value)
inline

◆ remove_if()

template<typename T, typename Allocator = std::allocator<T>>
template<class UnaryPred>
requires (std::predicate<UnaryPred&, const T&>)
void forward_lists< T, Allocator >::remove_if ( UnaryPred p)
inline

◆ remove_if_count()

template<typename T, typename Allocator = std::allocator<T>>
template<class UnaryPred>
requires (std::predicate<UnaryPred&,const T&>)
std::size_t forward_lists< T, Allocator >::remove_if_count ( UnaryPred p)
inline

◆ resize() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::resize ( std::size_t count)
inline

resize adalah method untuk mengubah ukuran sebuah list

  • If count is equal to the current size, does nothing.
  • If the current size is greater than count, the container is reduced to its first count elements.
  • If the current size is less than count, then: -1) Additional default-inserted elements are appended. -2) Additional copies of value are appended.

◆ resize() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::resize ( std::size_t count,
const T & value )
inline

◆ reverse()

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::reverse ( )
inline

◆ sort() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::sort ( )
inline

◆ sort() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
template<typename Compare = std::less<T>>
void forward_lists< T, Allocator >::sort ( Compare comp = Compare{})
inline

◆ splice_after() [1/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::splice_after ( const Iterator pos,
forward_lists< T, Allocator > && others )
inline

◆ splice_after() [2/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::splice_after ( const Iterator pos,
forward_lists< T, Allocator > && others,
const Iterator first,
const Iterator last )
inline

◆ splice_after() [3/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::splice_after ( const Iterator pos,
forward_lists< T, Allocator > && others,
const Iterator It )
inline

◆ splice_after() [4/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::splice_after ( const Iterator pos,
forward_lists< T, Allocator > & others )
inline

◆ splice_after() [5/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::splice_after ( const Iterator pos,
forward_lists< T, Allocator > & others,
const Iterator first,
const Iterator last )
inline

◆ splice_after() [6/6]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::splice_after ( const Iterator pos,
forward_lists< T, Allocator > & others,
const Iterator It )
inline

slice after method untuk memindahkan node dari satu list ke list lain tanpa menyalin data,tetapi move node pointer

Time complexity overloads

  • void splice_after( const_iterator pos, forward_list& other ) -> O(1)
  • void splice_after( const_iterator pos, forward_list&& other ) -> O(1)
  • void splice_after( const_iterator pos, forward_list& other, const_iterator it ) -> O(1)
  • void splice_after( const_iterator pos, forward_list&& other, const_iterator it ) ->O(1)
  • void splice_after( const_iterator pos, forward_list& other, const_iterator first, const_iterator last ) -> O(n)

◆ swap() [1/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::swap ( forward_lists< T, Allocator > && others)
inlinenoexcept

◆ swap() [2/2]

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::swap ( forward_lists< T, Allocator > & others)
inlinenoexcept

◆ uniqe()

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::uniqe ( )
inline

◆ uniqe_all()

template<typename T, typename Allocator = std::allocator<T>>
void forward_lists< T, Allocator >::uniqe_all ( )
inline

Member Data Documentation

◆ alloc

template<typename T, typename Allocator = std::allocator<T>>
node_allocator_type forward_lists< T, Allocator >::alloc
private

◆ head

template<typename T, typename Allocator = std::allocator<T>>
Node* forward_lists< T, Allocator >::head = nullptr
private

◆ size

template<typename T, typename Allocator = std::allocator<T>>
int forward_lists< T, Allocator >::size
private

◆ tail

template<typename T, typename Allocator = std::allocator<T>>
Node* forward_lists< T, Allocator >::tail
private

The documentation for this class was generated from the following file: