up

A priority search queue and LRU cache.
git clone git://git.jtobin.io/up.git
Log | Files | Refs

up_del.c (1053B)


      1 #include "all.h"
      2 
      3 u3_noun
      4 u3qdu_del(u3_noun a, u3_noun k)
      5 {
      6   u3_noun ded = u3qdu_qat_dew(a, k);
      7 
      8   if (u3_nul == ded) {
      9     return u3k(a);
     10   }
     11   else {
     12     u3_noun pv, qv, rv, sv;
     13     u3_noun vrv, trv;
     14 
     15     u3x_qual(u3t(ded), &pv, &qv, &rv, &sv);
     16     u3x_cell(rv, &vrv, &trv);
     17 
     18     if (c3y == u3r_sing(k, pv)) {
     19 
     20       u3_noun low = u3qdu_qor_bot(trv);
     21 
     22       if (u3_nul == low) {
     23         u3_noun pro = u3k(sv);
     24 
     25         u3z(ded);
     26         return pro;
     27       }
     28       else {
     29         u3_noun kl, pl, vl;
     30         u3x_trel(u3t(low), &kl, &pl, &vl);
     31 
     32         u3_noun pro = u3qdu_qat_raw(sv, kl, pl, vl);
     33 
     34         u3z(ded);
     35         u3z(low);
     36 
     37         return pro;
     38       }
     39     }
     40     else {
     41       u3_noun buc = u3nc(u3k(vrv), u3qdu_qor_del(trv, k));
     42       u3_noun pro = u3qdu_qat_raw(sv, pv, qv, buc);
     43 
     44       u3z(ded);
     45       u3z(buc);
     46 
     47       return pro;
     48     }
     49   }
     50 }
     51 
     52 u3_noun
     53 u3wdu_del(u3_noun cor)
     54 {
     55   u3_noun a, k;
     56 
     57   if ( (c3n == u3r_mean(cor, u3x_sam_2, &a, u3x_sam_3, &k, 0)) )
     58   {
     59     return u3m_bail(c3__exit);
     60   } else {
     61     return u3qdu_del(a, k);
     62   }
     63 }
     64