summaryrefslogtreecommitdiff
path: root/src/libdatastruct/avlnode_extreme.c
blob: cfdf98c1a5c39fc862bd6951e2d5bb1dd066c2c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
/* ISC license. */

#include <stdint.h>
#include <errno.h>
#include <skalibs/avlnode.h>

int avlnode_extreme (avlnode const *s, uint32_t max, uint32_t r, int h, uint32_t *k)
{
  uint32_t i = avlnode_extremenode(s, max, r, h) ;
  if (i >= max) return (errno = ESRCH, 0) ;
  *k = s[i].data ;
  return 1 ;
}