data_structures
rbt_max.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* rbt_max.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/18 19:17:38 by unite #+# #+# */
10 /* Updated: 2020/09/04 20:03:19 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "rbt.h"
15 
16 void *rbt_max(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->right)
24  node = node->right;
25  return (node->key);
26 }
rbt_max
void * rbt_max(const t_rbt *rbt)
Returns the largest key in the tree.
Definition: rbt_max.c:16
s_rbt
A left-leaning red-black binary search tree.
Definition: rbt.h:72
s_rbt_node::right
struct s_rbt_node * right
The right child.
Definition: rbt.h:56
s_rbt_node::key
void * key
The key.
Definition: rbt.h:53
rbt.h
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