skalibs

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

avlnode_doublerotate.c (482B)


      1 /* ISC license. */
      2 
      3 #include <skalibs/avlnode.h>
      4 #include "avlnode-internal.h"
      5 
      6 uint32_t avlnode_doublerotate (avlnode_ref s, uint32_t max, uint32_t i, int h)
      7 {
      8   uint32_t j = s[i].child[!h] ;
      9   uint32_t k = s[j].child[h] ;
     10   s[i].child[!h] = s[k].child[h] ;
     11   s[j].child[h] = s[k].child[!h] ;
     12   s[k].child[!h] = j ;
     13   s[k].child[h] = i ;
     14   s[h ? i : j].balance = (s[k].balance < 0) ;
     15   s[h ? j : i].balance = -(s[k].balance > 0) ;
     16   s[k].balance = 0 ;
     17   (void)max ;
     18   return k ;
     19 }