diff --git a/src/sauerlib/tools.hh b/src/sauerlib/tools.hh index faaf234..4b24ab2 100644 --- a/src/sauerlib/tools.hh +++ b/src/sauerlib/tools.hh @@ -337,9 +337,6 @@ struct databuf typedef databuf ucharbuf; -template -static inline float heapscore(const T &n) { return n; } - struct sortless { template bool operator()(const T &x, const T &y) const { return x < y; } @@ -731,59 +728,6 @@ template struct vector loopi(ulen/2) swap(buf[i], buf[ulen-1-i]); } - static int heapparent(int i) { return (i - 1) >> 1; } - static int heapchild(int i) { return (i << 1) + 1; } - - void buildheap() - { - for(int i = ulen/2; i >= 0; i--) downheap(i); - } - - int upheap(int i) - { - float score = heapscore(buf[i]); - while(i > 0) - { - int pi = heapparent(i); - if(score >= heapscore(buf[pi])) break; - swap(buf[i], buf[pi]); - i = pi; - } - return i; - } - - T &addheap(const T &x) - { - add(x); - return buf[upheap(ulen-1)]; - } - - int downheap(int i) - { - float score = heapscore(buf[i]); - for(;;) - { - int ci = heapchild(i); - if(ci >= ulen) break; - float cscore = heapscore(buf[ci]); - if(score > cscore) - { - if(ci+1 < ulen && heapscore(buf[ci+1]) < cscore) { swap(buf[ci+1], buf[i]); i = ci+1; } - else { swap(buf[ci], buf[i]); i = ci; } - } - else if(ci+1 < ulen && heapscore(buf[ci+1]) < score) { swap(buf[ci+1], buf[i]); i = ci+1; } - else break; - } - return i; - } - - T removeheap() - { - T e = removeunordered(0); - if(ulen) downheap(0); - return e; - } - template int htfind(const K &key) {