lstadd_front
void ft_lstadd_front(t_list **lst, t_list *new)
- lst: ๋ฆฌ์คํธ์ ์ฒซ ๋ ธ๋๋ฅผ ๊ฐ๋ฆฌํค๋ ํฌ์ธํฐ์ ์ฃผ์ (ํค๋ ํฌ์ธํฐ์ ์ฃผ์)
- new: ์์ ์ถ๊ฐํ ์๋ก์ด ๋ ธ๋
new->next = *lst;
: ๊ธฐ์กด ์ฒซ ๋ ธ๋๋ฅผnew->next
์ ์ฐ๊ฒฐํ๋ค.*lst = new;
:new
๊ฐ ๋ฆฌ์คํธ์ ์ฒซ ๋ ธ๋๊ฐ ๋๋๋กlst
๋ฅผ ๊ฐฑ์ ํ๋ค.
lst == NULL
๊ณผ *lst == NULL
์ ์ฐจ์ด
lst == NULL
: ๋ฆฌ์คํธ์ ์์ ์ฃผ์๊ฐ ์๋ค. ์ฆ, ๋ฆฌ์คํธ ์์ฒด๊ฐ ์กด์ฌํ์ง ์๋๋ค๋ ๋ป์ด๋ค.*lst == NULL
: ๋ฆฌ์คํธ๋ ์กด์ฌํ์ง๋ง, ์ฒซ ๋ ธ๋(head)๊ฐ ์๋ค. ์ฆ, ๋น์ด ์๋ ๋ฆฌ์คํธ๋ผ๋ ๋ป์ด๋ค.
lstdelone
void ft_lstdelone(t_list *lst, void (*del)(void *))
lst
๊ฐNULL
์ด๋ฉด ๋ฆฌ์คํธ๊ฐ ๋น์ด ์๋ค๋ ๋ป์ด๋ค. ์ด๋๋ ์ญ์ ํ ๋ฆฌ์คํธ๊ฐ ์๋ ๊ฒ์ด๋ฏ๋กreturn;
del()
ํจ์๊ฐNULL
์ด๋ฉดlst
์content
๋ฅผfree
ํ๋ ๊ธฐ๋ฅ์ ์ํํ์ง ๋ชปํ๋ฏ๋ก ๋ฐ๋กreturn;
void (*del)(void *)
:lst
์content
๋ฉค๋ฒ๋ณ์๋ฅผfree
ํ๊ธฐ ์ํ ํจ์ ํฌ์ธํฐ
lstmap
t_list *ft_lstmap(t_list *lst, void *(*f)(void *), void(*del)(void *))
- ๋ฆฌ์คํธ๊ฐ ๋น์๊ฑฐ๋
f
,del
ํจ์๊ฐNULL
์ด๋ฉดNULL
๋ฆฌํด - ์๋ก์ด ๋ฆฌ์คํธ
ret
๋ฅผNULL
์ด๊ธฐํ - ์๋ณธ ๋ฆฌ์คํธ
lst
๋ฅผ ์ํ:f(lst->content)
๋ก ์content
์์ฑft_lstnew(new_content)
๋ก ์ ๋ ธ๋ ์์ฑ- ์คํจ ์
lstclear
ํ ๋ฆฌํด ft_lstadd_back
์ผ๋ก ์๋ก์ด ๋ฆฌ์คํธ์ ์ถ๊ฐ
ret
๋ฆฌํด