data_structures
rbt_min.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* rbt_min.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/18 19:16:19 by unite #+# #+# */
10 /* Updated: 2020/09/04 20:03:14 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "rbt.h"
15 
16 void *rbt_min(const t_rbt *rbt)
17 {
18  t_rbt_node *node;
19 
20  if (!rbt->root)
21  return (NULL);
22  node = rbt->root;
23  while (node->left)
24  node = node->left;
25  return (node->key);
26 }
s_rbt
A left-leaning red-black binary search tree.
Definition: rbt.h:72
s_rbt_node::left
struct s_rbt_node * left
The left child.
Definition: rbt.h:55
s_rbt_node::key
void * key
The key.
Definition: rbt.h:53
rbt.h
rbt_min
void * rbt_min(const t_rbt *rbt)
Returns the smallest key in the tree.
Definition: rbt_min.c:16
s_rbt_node
A node in a red-black tree.
Definition: rbt.h:51
s_rbt::root
t_rbt_node * root
The root of the tree.
Definition: rbt.h:74