Skip to content

Commit

Permalink
creating new linked list reader for t_stack
Browse files Browse the repository at this point in the history
  • Loading branch information
biralavor committed Jun 8, 2024
1 parent 5a0e811 commit 51a5fc2
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
3 changes: 2 additions & 1 deletion program_to_test/headers/push_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: umeneses <umeneses@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/08 15:23:33 by umeneses #+# #+# */
/* Updated: 2024/06/07 16:15:17 by umeneses ### ########.fr */
/* Updated: 2024/06/08 14:55:58 by umeneses ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -45,6 +45,7 @@ int ft_argv_size(char **argv);
bool ft_argv_validation(char **argv);
/* new functions for push_swap to be added in LIBFT */

int ft_lst_size(t_stack *stack);
void ft_swap(t_stack **stack);
void ft_swap_ab(t_stack **stack_a, t_stack **stack_b);
void ft_push_a(t_stack **stack_a, t_stack **stack_b);
Expand Down
6 changes: 3 additions & 3 deletions program_to_test/src/ft_do_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: umeneses <umeneses@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/06/06 18:46:55 by umeneses #+# #+# */
/* Updated: 2024/06/07 15:05:22 by umeneses ### ########.fr */
/* Updated: 2024/06/08 14:41:50 by umeneses ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -18,9 +18,9 @@ void ft_do_sort(t_stack **stack_a, t_stack **stack_b)

if (!ft_is_sorted(*stack_a))
{
if (ft_lstsize_int((t_list *)*stack_a) == 2)
if (ft_lst_size(*stack_a) == 2)
ft_sort_2_nbrs(stack_a);
if (ft_lstsize_int((t_list *)*stack_a) == 3)
if (ft_lst_size(*stack_a) == 3)
ft_sort_3_nbrs(stack_a);
}
}
15 changes: 14 additions & 1 deletion program_to_test/src/ft_lst_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,25 @@
/* By: umeneses <umeneses@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/05/13 14:49:58 by umeneses #+# #+# */
/* Updated: 2024/06/07 16:13:51 by umeneses ### ########.fr */
/* Updated: 2024/06/08 14:56:38 by umeneses ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"

int ft_lst_size(t_stack *stack)
{
int size;

size = 0;
while (stack)
{
size++;
stack = stack->next;
}
return (size);
}

t_stack *ft_lst_init(int value)
{
t_stack *new_node;
Expand Down

0 comments on commit 51a5fc2

Please sign in to comment.