trying to work
This commit is contained in:
parent
3d3d7a35ab
commit
2776ee1ebc
25 changed files with 1621 additions and 0 deletions
37
src/app/moves/push.c
Normal file
37
src/app/moves/push.c
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* push.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 16:22:54 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/01/11 17:17:45 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/element.h"
|
||||
#include "app/state.h"
|
||||
#include "me/vec/vec_element.h"
|
||||
|
||||
static inline void push_inner(t_vec_element *to, t_vec_element *from,
|
||||
t_const_str tag)
|
||||
{
|
||||
t_element e;
|
||||
|
||||
(void)(tag);
|
||||
if (from->len == 0)
|
||||
return;
|
||||
vec_element_pop(from, &e);
|
||||
vec_element_push(to, e);
|
||||
}
|
||||
|
||||
void push_a(t_state *s)
|
||||
{
|
||||
push_inner(&s->stack_a, &s->stack_b, "Push A");
|
||||
}
|
||||
|
||||
void push_b(t_state *s)
|
||||
{
|
||||
push_inner(&s->stack_b, &s->stack_a, "Push B");
|
||||
}
|
||||
35
src/app/moves/rev_rotate.c
Normal file
35
src/app/moves/rev_rotate.c
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* rev_rotate.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 16:26:04 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/01/11 17:31:44 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/element.h"
|
||||
#include "app/state.h"
|
||||
|
||||
static inline void rev_rotate_inner(t_vec_element *stack, t_const_str tag)
|
||||
{
|
||||
t_element e;
|
||||
|
||||
(void)(tag);
|
||||
if (stack->len <= 1)
|
||||
return;
|
||||
vec_element_pop(stack, &e);
|
||||
vec_element_push_front(stack, e);
|
||||
}
|
||||
|
||||
void rev_rotate_a(t_state *s)
|
||||
{
|
||||
rev_rotate_inner(&s->stack_a, "RevRotate A");
|
||||
}
|
||||
|
||||
void rev_rotate_b(t_state *s)
|
||||
{
|
||||
rev_rotate_inner(&s->stack_b, "RevRotate B");
|
||||
}
|
||||
36
src/app/moves/rotate.c
Normal file
36
src/app/moves/rotate.c
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* rotate.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 16:26:04 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/01/11 17:31:20 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/element.h"
|
||||
#include "app/state.h"
|
||||
|
||||
|
||||
static inline void rotate_inner(t_vec_element *stack, t_const_str tag)
|
||||
{
|
||||
t_element e;
|
||||
|
||||
(void)(tag);
|
||||
if (stack->len <= 1)
|
||||
return;
|
||||
vec_element_pop(stack, &e);
|
||||
vec_element_push_front(stack, e);
|
||||
}
|
||||
|
||||
void rotate_a(t_state *s)
|
||||
{
|
||||
rotate_inner(&s->stack_a, "Rotate A");
|
||||
}
|
||||
|
||||
void rotate_b(t_state *s)
|
||||
{
|
||||
rotate_inner(&s->stack_b, "Rotate B");
|
||||
}
|
||||
39
src/app/moves/swap.c
Normal file
39
src/app/moves/swap.c
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/* ************************************************************************** */
|
||||
/* */
|
||||
/* ::: :::::::: */
|
||||
/* swap.c :+: :+: :+: */
|
||||
/* +:+ +:+ +:+ */
|
||||
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
|
||||
/* +#+#+#+#+#+ +#+ */
|
||||
/* Created: 2024/01/11 16:26:04 by maiboyer #+# #+# */
|
||||
/* Updated: 2024/01/11 17:56:12 by maiboyer ### ########.fr */
|
||||
/* */
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "app/element.h"
|
||||
#include "app/state.h"
|
||||
#include "me/vec/vec_element.h"
|
||||
|
||||
static inline void swap_inner(t_vec_element *stack, t_const_str tag)
|
||||
{
|
||||
t_element first;
|
||||
t_element second;
|
||||
|
||||
(void)(tag);
|
||||
if (stack->len <= 1)
|
||||
return;
|
||||
vec_element_pop(stack, &first);
|
||||
vec_element_pop(stack, &second);
|
||||
vec_element_push(stack, first);
|
||||
vec_element_push(stack, second);
|
||||
}
|
||||
|
||||
void swap_a(t_state *s)
|
||||
{
|
||||
swap_inner(&s->stack_a, "Swap A");
|
||||
}
|
||||
|
||||
void swap_b(t_state *s)
|
||||
{
|
||||
swap_inner(&s->stack_b, "Swap B");
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue