skalibs

Mirror/fork of https://skarnet.org/software/skalibs/
git clone https://ccx.te2000.cz/git/skalibs
Log | Files | Refs | README | LICENSE

avlnode_rotate.c (390B)


      1 /* ISC license. */
      2 
      3 #include <skalibs/avlnode.h>
      4 #include "avlnode-internal.h"
      5 
      6 uint32_t avlnode_rotate (avlnode *s, uint32_t max, uint32_t i, int h)
      7 {
      8   uint32_t j = s[i].child[!h] ;
      9   s[i].child[!h] = s[j].child[h] ;
     10   s[j].child[h] = i ;
     11   if (s[j].balance * avlnode_sfromu(h) < 0) s[i].balance = s[j].balance = 0 ;
     12   else s[j].balance = avlnode_sfromu(h) ;
     13   (void)max ;
     14   return j ;
     15 }