Skip to content

Commit

Permalink
rename is_opt -> is_target
Browse files Browse the repository at this point in the history
  • Loading branch information
rask24 committed Feb 14, 2024
1 parent 314606a commit 627777b
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 32 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ SRC = $(SRC_DIR)/main.c \
$(SRC_DIR)/sort/large_sort/push_b_segmented.c \
$(SRC_DIR)/sort/large_sort/set_cost.c \
$(SRC_DIR)/sort/large_sort/set_min_cost_opt_method.c \
$(SRC_DIR)/sort/large_sort/set_is_opt.c \
$(SRC_DIR)/sort/large_sort/set_is_target.c \
$(SRC_DIR)/sort/large_sort/greedy_operation.c \
$(SRC_DIR)/stack_operations/push.c \
$(SRC_DIR)/stack_operations/swap.c \
Expand Down Expand Up @@ -67,7 +67,7 @@ TEST_SRC = $(TEST_DIR)/test_check_args.cpp \
$(TEST_DIR)/test_push_b_segmented.cpp \
$(TEST_DIR)/test_set_cost.cpp \
$(TEST_DIR)/test_set_min_cost_opt_method.cpp \
$(TEST_DIR)/test_set_is_opt.cpp \
$(TEST_DIR)/test_set_is_target.cpp \
$(TEST_DIR)/test_greedy_operation.cpp \
$(TEST_DIR)/test_is_sorted_stack.cpp \
$(TEST_DIR)/test_sort.cpp
Expand Down
4 changes: 2 additions & 2 deletions include/large_sort.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:36:38 by reasuke #+# #+# */
/* Updated: 2024/02/14 14:44:13 by reasuke ### ########.fr */
/* Updated: 2024/02/14 16:41:29 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -19,7 +19,7 @@ void large_sort(t_stack **p_a, t_stack **p_b);
void push_b_segmented(t_stack **p_a, t_stack **p_b, int n, int num_seg);
void set_cost(t_stack **p_a, t_stack **p_b);
void set_min_cost_opt_method(t_stack **p_b);
void set_is_opt(t_stack **p_b);
void set_is_target(t_stack **p_b);
void greedy_operation(t_stack **p_a, t_stack **p_b);

#endif
4 changes: 2 additions & 2 deletions include/types.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:57:41 by reasuke #+# #+# */
/* Updated: 2024/02/14 14:24:17 by reasuke ### ########.fr */
/* Updated: 2024/02/14 16:40:21 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -34,6 +34,6 @@ typedef struct s_content
int rra_cost;
int min_cost;
t_method opt_method;
bool is_opt;
bool is_target;
} t_content;
#endif
4 changes: 2 additions & 2 deletions src/sort/large_sort/greedy_operation.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/10 10:43:16 by reasuke #+# #+# */
/* Updated: 2024/02/14 14:20:41 by reasuke ### ########.fr */
/* Updated: 2024/02/14 16:40:21 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand All @@ -19,7 +19,7 @@ static t_stack *_find_opt_st_b(t_stack **p_b)
t_stack *st_b;

st_b = *p_b;
while (!get_content(st_b)->is_opt)
while (!get_content(st_b)->is_target)
st_b = st_b->next;
return (st_b);
}
Expand Down
4 changes: 2 additions & 2 deletions src/sort/large_sort/large_sort.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/22 16:55:10 by reasuke #+# #+# */
/* Updated: 2024/02/14 14:45:15 by reasuke ### ########.fr */
/* Updated: 2024/02/14 16:41:29 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -59,7 +59,7 @@ void large_sort(t_stack **p_a, t_stack **p_b)
{
set_cost(p_a, p_b);
set_min_cost_opt_method(p_b);
set_is_opt(p_b);
set_is_target(p_b);
greedy_operation(p_a, p_b);
}
_sort_stack_a(p_a, size_a);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* set_is_opt.c :+: :+: :+: */
/* set_is_target.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: reasuke <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/02/14 14:44:38 by reasuke #+# #+# */
/* Updated: 2024/02/14 16:22:59 by reasuke ### ########.fr */
/* Updated: 2024/02/14 16:42:11 by reasuke ### ########.fr */
/* */
/* ************************************************************************** */

Expand Down Expand Up @@ -46,7 +46,7 @@ static int _calc_target_index(t_stack *st_b, int max_seg)
return (target_index);
}

void set_is_opt(t_stack **p_b)
void set_is_target(t_stack **p_b)
{
int i;
t_stack *st_b;
Expand All @@ -59,5 +59,5 @@ void set_is_opt(t_stack **p_b)
i = 0;
while (i++ < target_index)
st_b = st_b->next;
get_content(st_b)->is_opt = true;
get_content(st_b)->is_target = true;
}
4 changes: 2 additions & 2 deletions test/test_greedy_operation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ static void greedy_operation_case1() {

set_cost(&stack_a, &stack_b);
set_min_cost_opt_method(&stack_b);
set_is_opt(&stack_b);
set_is_target(&stack_b);
greedy_operation(&stack_a, &stack_b);

std::vector<int> after_a = {1, 2, 4, 6, 8, 0};
Expand Down Expand Up @@ -135,7 +135,7 @@ static void greedy_operation_case2() {

set_cost(&stack_a, &stack_b);
set_min_cost_opt_method(&stack_b);
set_is_opt(&stack_b);
set_is_target(&stack_b);
greedy_operation(&stack_a, &stack_b);

std::vector<int> after_a = {5, 6, 7, 1, 3, 4};
Expand Down
32 changes: 16 additions & 16 deletions test/test_set_is_opt.cpp → test/test_set_is_target.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ extern "C" {
// (-1, 0)
// 4 4 1 1: 1

TEST(set_is_opt, case1_segment_not_set) {
TEST(set_is_target, case1_segment_not_set) {
int N;
t_stack *stack_a;
t_stack *stack_b;
Expand All @@ -45,15 +45,15 @@ TEST(set_is_opt, case1_segment_not_set) {
}
set_cost(&stack_a, &stack_b);
set_min_cost_opt_method(&stack_b);
set_is_opt(&stack_b);
set_is_target(&stack_b);

t_stack *st = stack_b;

for (int i = 0; i < N; ++i) {
if (i == 0)
EXPECT_EQ(get_content(st)->is_opt, true);
EXPECT_EQ(get_content(st)->is_target, true);
else
EXPECT_EQ(get_content(st)->is_opt, false);
EXPECT_EQ(get_content(st)->is_target, false);
st = st->next;
}
}
Expand All @@ -80,7 +80,7 @@ TEST(set_is_opt, case1_segment_not_set) {
// 4 4 1 1: 1
// ==== segment 0 ====> target

TEST(set_is_opt, case1_segment_set) {
TEST(set_is_target, case1_segment_set) {
int N;
t_stack *stack_a;
t_stack *stack_b;
Expand All @@ -100,15 +100,15 @@ TEST(set_is_opt, case1_segment_set) {
get_content(ft_lstlast(stack_b))->segment = 0;
set_cost(&stack_a, &stack_b);
set_min_cost_opt_method(&stack_b);
set_is_opt(&stack_b);
set_is_target(&stack_b);

t_stack *st = stack_b;

for (int i = 0; i < N; ++i) {
if (i == 4)
EXPECT_EQ(get_content(st)->is_opt, true);
EXPECT_EQ(get_content(st)->is_target, true);
else
EXPECT_EQ(get_content(st)->is_opt, false);
EXPECT_EQ(get_content(st)->is_target, false);
st = st->next;
}
}
Expand All @@ -130,7 +130,7 @@ TEST(set_is_opt, case1_segment_set) {
// RRA_RRB: (-1, 0)
// 4 1 4 1: 1

TEST(set_is_opt, case2_segment_not_set) {
TEST(set_is_target, case2_segment_not_set) {
int N = 5;
t_stack *stack_a;
t_stack *stack_b;
Expand All @@ -151,15 +151,15 @@ TEST(set_is_opt, case2_segment_not_set) {

set_cost(&stack_a, &stack_b);
set_min_cost_opt_method(&stack_b);
set_is_opt(&stack_b);
set_is_target(&stack_b);

t_stack *st = stack_b;

for (int i = 0; i < N; ++i) {
if (i == 4)
EXPECT_EQ(get_content(st)->is_opt, true);
EXPECT_EQ(get_content(st)->is_target, true);
else
EXPECT_EQ(get_content(st)->is_opt, false);
EXPECT_EQ(get_content(st)->is_target, false);
st = st->next;
}
}
Expand All @@ -186,7 +186,7 @@ TEST(set_is_opt, case2_segment_not_set) {
// 4 1 4 1: 1
// ==== segment -1 ====

TEST(set_is_opt, case2_segment_set) {
TEST(set_is_target, case2_segment_set) {
int N = 5;
t_stack *stack_a;
t_stack *stack_b;
Expand All @@ -213,15 +213,15 @@ TEST(set_is_opt, case2_segment_set) {

set_cost(&stack_a, &stack_b);
set_min_cost_opt_method(&stack_b);
set_is_opt(&stack_b);
set_is_target(&stack_b);

t_stack *st = stack_b;

for (int i = 0; i < N; ++i) {
if (i == 3)
EXPECT_EQ(get_content(st)->is_opt, true);
EXPECT_EQ(get_content(st)->is_target, true);
else
EXPECT_EQ(get_content(st)->is_opt, false);
EXPECT_EQ(get_content(st)->is_target, false);
st = st->next;
}
}

0 comments on commit 627777b

Please sign in to comment.