Skip to content

Commit

Permalink
fix module (#47)
Browse files Browse the repository at this point in the history
* fix order stack_operations.h

* fix module

* fix performance test
  • Loading branch information
rask24 committed Feb 20, 2024
1 parent df0605d commit 42bde60
Show file tree
Hide file tree
Showing 33 changed files with 62 additions and 100 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ source "https://rubygems.org"
gem "rspec"
gem "open3"
gem "rubocop-shopify", require: false
gem "descriptive_statistics"
2 changes: 2 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
descriptive_statistics (2.5.1)
diff-lcs (1.5.1)
json (2.7.1)
language_server-protocol (3.17.0.3)
Expand Down Expand Up @@ -50,6 +51,7 @@ PLATFORMS
ruby

DEPENDENCIES
descriptive_statistics
open3
rspec
rubocop-shopify
Expand Down
5 changes: 2 additions & 3 deletions include/checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/14 10:26:54 by reasuke #+# #+# */
/* Updated: 2024/02/19 12:11:08 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:19:45 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#ifndef CHECKER_H
# define CHECKER_H

# include "../libft/libft.h"
# include "types.h"
# include "push_swap.h"

void sort_based_on_operation(t_stack **p_a, t_stack **p_b);

Expand Down
23 changes: 0 additions & 23 deletions include/main.h

This file was deleted.

7 changes: 1 addition & 6 deletions include/push_swap.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/10 12:37:54 by reasuke #+# #+# */
/* Updated: 2024/02/13 12:45:48 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:19:53 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -21,9 +21,4 @@
# include <stdlib.h>
# include <unistd.h>

int check_args(int argc, char **argv);
t_stack *generate_stack(int argc, char **argv);

void sort(t_stack **p_a, t_stack **p_b);

#endif
21 changes: 11 additions & 10 deletions include/stack_operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/11 12:41:01 by reasuke #+# #+# */
/* Updated: 2024/02/11 12:41:49 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:16:47 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -15,8 +15,17 @@

# include "push_swap.h"

void operate_sa(t_stack **p_a);
void push_stack(t_stack **p_s1, t_stack **p_s2);
void swap_stack(t_stack **p_stack);
void rotate_stack(t_stack **p_stack);
void reverse_rotate_stack(t_stack **p_stack);

void do_single_n_operations(t_stack **p_st, int n,
void (*operation)(t_stack **));
void do_double_n_operations(t_stack **p_a, t_stack **p_b, int n,
void (*operation)(t_stack **, t_stack **));

void operate_sa(t_stack **p_a);
void operate_sb(t_stack **p_b);
void operate_ss(t_stack **p_a, t_stack **p_b);
void operate_ra(t_stack **p_a);
Expand All @@ -27,13 +36,5 @@ void operate_rrb(t_stack **p_a);
void operate_rrr(t_stack **p_a, t_stack **p_b);
void operate_pa(t_stack **p_b, t_stack **p_a);
void operate_pb(t_stack **p_a, t_stack **p_b);
void do_single_n_operations(t_stack **p_st, int n,
void (*operation)(t_stack **));
void do_double_n_operations(t_stack **p_a, t_stack **p_b, int n,
void (*operation)(t_stack **, t_stack **));

void push_stack(t_stack **p_s1, t_stack **p_s2);
void swap_stack(t_stack **p_stack);
void rotate_stack(t_stack **p_stack);
void reverse_rotate_stack(t_stack **p_stack);
#endif
3 changes: 1 addition & 2 deletions src/initialization/check_args.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 14:44:55 by reasuke #+# #+# */
/* Updated: 2024/02/19 12:56:30 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:19:12 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "initialization.h"
#include "push_swap.h"

static bool _has_not_digit(int argc, char **argv)
{
Expand Down
3 changes: 1 addition & 2 deletions src/initialization/exit_with_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 14:38:17 by reasuke #+# #+# */
/* Updated: 2024/02/13 11:46:04 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:19:14 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "initialization.h"
#include "push_swap.h"

void exit_with_error(void)
{
Expand Down
3 changes: 1 addition & 2 deletions src/initialization/generate_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/11 19:04:40 by reasuke #+# #+# */
/* Updated: 2024/02/14 14:28:39 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:19:17 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "initialization.h"
#include "push_swap.h"

int *_allocate_int_array(int size_a)
{
Expand Down
5 changes: 3 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/10 12:37:36 by reasuke #+# #+# */
/* Updated: 2024/02/19 12:06:15 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:21:01 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "initialization.h"
#include "sort.h"

#ifdef LEAK
# ifdef __APPLE__
Expand Down
3 changes: 1 addition & 2 deletions src/sort/is_sorted_stack.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/10 18:47:11 by reasuke #+# #+# */
/* Updated: 2024/02/13 14:01:58 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:18:06 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "sort.h"

bool is_sorted_stack(t_stack *st)
Expand Down
3 changes: 1 addition & 2 deletions src/sort/large_sort/greedy_operation.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/10 10:43:16 by reasuke #+# #+# */
/* Updated: 2024/02/14 16:40:21 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:17:27 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "large_sort.h"
#include "push_swap.h"
#include "stack_operations.h"

static t_stack *_find_opt_st_b(t_stack **p_b)
Expand Down
3 changes: 1 addition & 2 deletions src/sort/large_sort/large_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/22 16:55:10 by reasuke #+# #+# */
/* Updated: 2024/02/15 12:34:14 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:17:35 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "large_sort.h"
#include "push_swap.h"
#include "sort.h"
#include "stack_operations.h"

Expand Down
3 changes: 1 addition & 2 deletions src/sort/large_sort/push_b_segmented.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/11 22:57:28 by reasuke #+# #+# */
/* Updated: 2024/02/14 14:31:29 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:17:46 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "large_sort.h"
#include "push_swap.h"
#include "stack_operations.h"

static int _calc_segment_id(int target, int n, int segs)
Expand Down
3 changes: 1 addition & 2 deletions src/sort/large_sort/set_cost.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/08 12:17:33 by reasuke #+# #+# */
/* Updated: 2024/02/14 14:15:57 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:17:50 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "large_sort.h"
#include "push_swap.h"

static int _calc_insertion_threshold(t_stack **p_a, t_stack *st_b)
{
Expand Down
3 changes: 1 addition & 2 deletions src/sort/large_sort/set_is_target.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/14 14:44:38 by reasuke #+# #+# */
/* Updated: 2024/02/14 16:42:11 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:17:53 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "large_sort.h"
#include "push_swap.h"

static int _calc_max_segment(t_stack *st_b)
{
Expand Down
3 changes: 1 addition & 2 deletions src/sort/large_sort/set_min_cost_opt_method.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/09 10:23:28 by reasuke #+# #+# */
/* Updated: 2024/02/14 15:44:15 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:18:02 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "large_sort.h"
#include "push_swap.h"

static int _calc_cost(t_stack *st_b, t_method method)
{
Expand Down
3 changes: 1 addition & 2 deletions src/sort/micro_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/15 16:32:27 by reasuke #+# #+# */
/* Updated: 2024/02/13 15:38:56 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:18:10 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "sort.h"
#include "stack_operations.h"

Expand Down
3 changes: 1 addition & 2 deletions src/sort/nano_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/12 15:58:22 by reasuke #+# #+# */
/* Updated: 2024/02/11 12:54:19 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:18:22 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "sort.h"
#include "stack_operations.h"

Expand Down
3 changes: 1 addition & 2 deletions src/sort/sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/15 15:10:35 by reasuke #+# #+# */
/* Updated: 2024/02/11 12:54:21 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:18:25 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "sort.h"

void sort(t_stack **p_a, t_stack **p_b)
Expand Down
4 changes: 2 additions & 2 deletions src/stack_operations/do_double_n_operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/10 19:22:50 by reasuke #+# #+# */
/* Updated: 2024/02/10 19:29:43 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:15:32 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "stack_operations.h"

void do_double_n_operations(t_stack **p_a, t_stack **p_b, int n,
void (*operation)(t_stack **, t_stack **))
Expand Down
4 changes: 2 additions & 2 deletions src/stack_operations/do_single_n_operations.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/10 19:22:26 by reasuke #+# #+# */
/* Updated: 2024/02/10 19:29:08 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:15:35 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "stack_operations.h"

void do_single_n_operations(t_stack **p_st, int n,
void (*operation)(t_stack **))
Expand Down
4 changes: 2 additions & 2 deletions src/stack_operations/push.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/15 15:56:53 by reasuke #+# #+# */
/* Updated: 2024/02/07 15:05:10 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:15:37 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "stack_operations.h"

void push_stack(t_stack **p_s1, t_stack **p_s2)
{
Expand Down
4 changes: 2 additions & 2 deletions src/stack_operations/reverse_rotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/23 17:18:15 by reasuke #+# #+# */
/* Updated: 2024/02/07 15:04:58 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:15:40 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "stack_operations.h"

void reverse_rotate_stack(t_stack **p_stack)
{
Expand Down
4 changes: 2 additions & 2 deletions src/stack_operations/rotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/15 14:05:46 by reasuke #+# #+# */
/* Updated: 2024/02/07 15:05:17 by reasuke ### ########.fr */
/* Updated: 2024/02/20 14:15:43 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

#include "push_swap.h"
#include "stack_operations.h"

void rotate_stack(t_stack **p_stack)
{
Expand Down
Loading

0 comments on commit 42bde60

Please sign in to comment.