Definition in file sort.c.
#include <stdlib.h>
#include "utils/utils.h"
#include "stack/stack.h"
Go to the source code of this file.
|
| static int | pick_i (t_stack *stack, int mode, int n) |
| | Find appropriate index for n in stack[mode]
|
| |
| static void | rot_i (t_stack *stack, int mode, int i) |
| | Rotate to an index with rotate or reverse rotate, depending on which is shorter.
|
| |
| static int | rot_cost (t_stack stack, int o_i, int o_len, int i) |
| | Determine move cost of rotating to an index, considering whether it is shorter to rotate or reverse rotate.
|
| |
| static void | pick (t_stack *stack, int mode, int *costs) |
| | Determine which element to push from stack mode to the opposite stack by comparing their movement costs.
|
| |
| int | sort (t_stack *stack) |
| | Output all instructions required to sort stack a.
|
| |
◆ pick()
| static void pick |
( |
t_stack * |
stack, |
|
|
int |
mode, |
|
|
int * |
costs |
|
) |
| |
|
static |
◆ pick_i()
| static int pick_i |
( |
t_stack * |
stack, |
|
|
int |
mode, |
|
|
int |
n |
|
) |
| |
|
static |
Find appropriate index for n in stack[mode]
- Parameters
-
- Return values
-
Definition at line 32 of file sort.c.
References get_minix().
◆ rot_cost()
| static int rot_cost |
( |
t_stack |
stack, |
|
|
int |
o_i, |
|
|
int |
o_len, |
|
|
int |
i |
|
) |
| |
|
static |
Determine move cost of rotating to an index, considering whether it is shorter to rotate or reverse rotate.
- Parameters
-
| [in] | stack | |
| [in] | o_i | |
| [in] | o_len | |
| [in] | i | |
- Return values
-
Definition at line 87 of file sort.c.
◆ rot_i()
| static void rot_i |
( |
t_stack * |
stack, |
|
|
int |
mode, |
|
|
int |
i |
|
) |
| |
|
static |
Rotate to an index with rotate or reverse rotate, depending on which is shorter.
- Parameters
-
| [in,out] | stack | |
| [in] | mode | |
| [in] | i | |
Definition at line 60 of file sort.c.
References r_rot(), and rot().
◆ sort()