aboutsummaryrefslogtreecommitdiff
path: root/src/common/stack_helper.c
blob: 31d0fea407d64310f02c36f8a60266f0673e9710 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   stack_helper.c                                     :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: cacharle <marvin@42.fr>                    +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/01/19 06:40:18 by cacharle          #+#    #+#             */
/*   Updated: 2020/01/21 11:08:06 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#include "common.h"

inline void	stack_swap_2(t_stack *stack_a, t_stack *stack_b)
{
	stack_swap(stack_a);
	stack_swap(stack_b);
}

inline void	stack_rotate_2(t_stack *stack_a, t_stack *stack_b)
{
	stack_rotate(stack_a);
	stack_rotate(stack_b);
}

inline void	stack_reverse_rotate_2(t_stack *stack_a, t_stack *stack_b)
{
	stack_reverse_rotate(stack_a);
	stack_reverse_rotate(stack_b);
}

inline t_bool	stack_empty(t_stack *stack)
{
	return (stack->top == -1);
}

inline int		stack_length(t_stack *stack)
{
	return (stack->top + 1);
}