push and pop
This commit is contained in:
parent
5d9de2f68a
commit
6ee8d4e4fc
9 changed files with 43 additions and 20 deletions
|
|
@ -6,7 +6,7 @@
|
||||||
# By: jhalford <jack@crans.org> +#+ +:+ +#+ #
|
# By: jhalford <jack@crans.org> +#+ +:+ +#+ #
|
||||||
# +#+#+#+#+#+ +#+ #
|
# +#+#+#+#+#+ +#+ #
|
||||||
# Created: 2017/02/07 16:09:36 by jhalford #+# #+# #
|
# Created: 2017/02/07 16:09:36 by jhalford #+# #+# #
|
||||||
# Updated: 2017/02/07 20:11:46 by jhalford ### ########.fr #
|
# Updated: 2017/02/10 00:26:46 by jhalford ### ########.fr #
|
||||||
# #
|
# #
|
||||||
# **************************************************************************** #
|
# **************************************************************************** #
|
||||||
|
|
||||||
|
|
@ -98,8 +98,9 @@ lst/ft_lstmap.c\
|
||||||
lst/ft_lstnadd.c\
|
lst/ft_lstnadd.c\
|
||||||
lst/ft_lstnew.c\
|
lst/ft_lstnew.c\
|
||||||
lst/ft_lstnew_range.c\
|
lst/ft_lstnew_range.c\
|
||||||
lst/ft_lstpop.c\
|
|
||||||
lst/ft_lstsort.c\
|
lst/ft_lstsort.c\
|
||||||
|
lst/pop.c\
|
||||||
|
lst/push.c\
|
||||||
math/ft_addrcmp.c\
|
math/ft_addrcmp.c\
|
||||||
math/ft_ilen.c\
|
math/ft_ilen.c\
|
||||||
math/ft_ilen_base.c\
|
math/ft_ilen_base.c\
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:49:04 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/02/07 16:12:40 by jhalford ### ########.fr */
|
/* Updated: 2017/02/10 00:27:21 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -22,14 +22,6 @@
|
||||||
# define DG_MSG1 ft_path_notdir(__FILE__), __LINE__
|
# define DG_MSG1 ft_path_notdir(__FILE__), __LINE__
|
||||||
# define DG(f, ...) ft_dprintf(STDBUG, DG_MSG0 f "{eoc}\n", DG_MSG1, ##__VA_ARGS__)
|
# define DG(f, ...) ft_dprintf(STDBUG, DG_MSG0 f "{eoc}\n", DG_MSG1, ##__VA_ARGS__)
|
||||||
|
|
||||||
# include "get_next_line.h"
|
|
||||||
# include "ft_xattr.h"
|
|
||||||
# include "mytime.h"
|
|
||||||
# include "lst.h"
|
|
||||||
# include "dlst.h"
|
|
||||||
# include "btree.h"
|
|
||||||
# include "color.h"
|
|
||||||
|
|
||||||
# include <string.h>
|
# include <string.h>
|
||||||
# include <unistd.h>
|
# include <unistd.h>
|
||||||
# include <stdio.h>
|
# include <stdio.h>
|
||||||
|
|
@ -38,13 +30,21 @@
|
||||||
# include <sys/xattr.h>
|
# include <sys/xattr.h>
|
||||||
# include <sys/acl.h>
|
# include <sys/acl.h>
|
||||||
|
|
||||||
|
# include "lst.h"
|
||||||
|
# include "get_next_line.h"
|
||||||
|
# include "ft_xattr.h"
|
||||||
|
# include "mytime.h"
|
||||||
|
# include "dlst.h"
|
||||||
|
# include "btree.h"
|
||||||
|
# include "color.h"
|
||||||
|
|
||||||
# define FT_WS(x) (x == ' ' || x == '\t' || x == '\n')
|
# define FT_WS(x) (x == ' ' || x == '\t' || x == '\n')
|
||||||
# define FT_ABS(x) (((x) < 0) ? -(x) : (x))
|
# define FT_ABS(x) (((x) < 0) ? -(x) : (x))
|
||||||
# define FT_NEG(x) ((x) < 0)
|
# define FT_NEG(x) ((x) < 0)
|
||||||
# define FT_POS(x) ((x) > 0)
|
# define FT_POS(x) ((x) > 0)
|
||||||
# define FT_MIN(a, b) ((a) < (b) ? (a) : (b))
|
# define FT_MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
# define FT_MAX(a, b) ((a) > (b) ? (a) : (b))
|
# define FT_MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
# define FT_DIST(a, b) (FT_ABS((a) - (b)))
|
# define FT_DIST(a, b) FT_ABS((a) - (b))
|
||||||
|
|
||||||
typedef struct s_stof t_stof;
|
typedef struct s_stof t_stof;
|
||||||
typedef struct s_stos t_stos;
|
typedef struct s_stos t_stos;
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */
|
/* Created: 2016/11/07 13:27:46 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/12/12 14:59:12 by jhalford ### ########.fr */
|
/* Updated: 2017/02/10 00:32:53 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
@ -24,6 +24,9 @@ struct s_list
|
||||||
|
|
||||||
typedef struct s_list t_list;
|
typedef struct s_list t_list;
|
||||||
|
|
||||||
|
t_list *pop(t_list **lst);
|
||||||
|
t_list *push(t_list **stack, int elem);
|
||||||
|
|
||||||
t_list *ft_lstnew(void const *content, size_t content_size);
|
t_list *ft_lstnew(void const *content, size_t content_size);
|
||||||
void ft_lstdel(t_list **alst, void (*del)(void *, size_t));
|
void ft_lstdel(t_list **alst, void (*del)(void *, size_t));
|
||||||
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t));
|
void ft_lstdelone(t_list **alst, void (*del)(void *, size_t));
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/03 14:57:13 by jhalford #+# #+# */
|
/* Created: 2016/11/03 14:57:13 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/04 11:09:44 by jhalford ### ########.fr */
|
/* Updated: 2017/02/09 21:50:08 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:48 by jhalford #+# #+# */
|
/* Created: 2016/11/04 11:09:48 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/04 11:09:49 by jhalford ### ########.fr */
|
/* Updated: 2017/02/09 20:46:28 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/29 15:57:38 by jhalford #+# #+# */
|
/* Created: 2016/11/29 15:57:38 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/29 15:57:40 by jhalford ### ########.fr */
|
/* Updated: 2017/02/09 21:37:14 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
/* */
|
/* */
|
||||||
/* ::: :::::::: */
|
/* ::: :::::::: */
|
||||||
/* ft_lstpop.c :+: :+: :+: */
|
/* pop.c :+: :+: :+: */
|
||||||
/* +:+ +:+ +:+ */
|
/* +:+ +:+ +:+ */
|
||||||
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/11/04 11:09:56 by jhalford #+# #+# */
|
/* Created: 2016/11/04 11:09:56 by jhalford #+# #+# */
|
||||||
/* Updated: 2016/11/29 13:46:21 by jhalford ### ########.fr */
|
/* Updated: 2017/02/10 00:33:21 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
#include "libft.h"
|
#include "libft.h"
|
||||||
|
|
||||||
t_list *ft_lstpop(t_list **lst)
|
t_list *pop(t_list **lst)
|
||||||
{
|
{
|
||||||
t_list *top;
|
t_list *top;
|
||||||
|
|
||||||
19
libft/src/lst/push.c
Normal file
19
libft/src/lst/push.c
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* push.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2017/02/09 15:59:39 by jhalford #+# #+# */
|
||||||
|
/* Updated: 2017/02/10 00:28:45 by jhalford ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "libft.h"
|
||||||
|
|
||||||
|
t_list *push(t_list **stack, int elem)
|
||||||
|
{
|
||||||
|
ft_lstadd(stack, ft_lstnew(&elem, sizeof(elem)));
|
||||||
|
return (*stack);
|
||||||
|
}
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
/* By: jhalford <jack@crans.org> +#+ +:+ +#+ */
|
||||||
/* +#+#+#+#+#+ +#+ */
|
/* +#+#+#+#+#+ +#+ */
|
||||||
/* Created: 2016/12/13 12:16:31 by jhalford #+# #+# */
|
/* Created: 2016/12/13 12:16:31 by jhalford #+# #+# */
|
||||||
/* Updated: 2017/01/22 17:46:19 by jhalford ### ########.fr */
|
/* Updated: 2017/02/09 17:34:47 by jhalford ### ########.fr */
|
||||||
/* */
|
/* */
|
||||||
/* ************************************************************************** */
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue