up

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

lu_ebb.c (675B)


      1 #include "all.h"
      2 
      3 u3_noun
      4 u3qdl_ebb(u3_noun a)
      5 {
      6   u3_noun cap_a, siz_a, tic_a, pri_a;
      7   u3x_qual(a, &cap_a, &siz_a, &tic_a, &pri_a);
      8 
      9   if (c3y == u3qa_gte(tic_a, 0x7fffffff)) {
     10     return u3nq(u3k(cap_a), 0, 0, u3_nul);
     11   }
     12   else if (c3y == u3qa_gth(siz_a, cap_a)) {
     13     return u3nq(u3k(cap_a), u3qa_dec(siz_a), u3k(tic_a), u3qdu_cut(pri_a));
     14   }
     15   else {
     16     return u3k(a);
     17   }
     18 }
     19 
     20 u3_noun
     21 u3kdl_ebb(u3_noun a)
     22 {
     23   u3_noun pro = u3qdl_ebb(a);
     24 
     25   u3z(a);
     26   return pro;
     27 }
     28 
     29 u3_noun
     30 u3wdl_ebb(u3_noun cor)
     31 {
     32   u3_noun a;
     33 
     34   if ( (c3n == u3r_mean(cor, u3x_sam, &a, 0)) ||
     35        (c3n == u3du(a)) )
     36   {
     37     return u3m_bail(c3__exit);
     38   } else {
     39     return u3qdl_ebb(a);
     40   }
     41 }
     42 
     43