remove unused code

master
Daniel Kolesa 2020-07-30 19:32:35 +02:00
parent 8da465a4fc
commit 79e41bd3d9
1 changed files with 0 additions and 56 deletions

View File

@ -337,9 +337,6 @@ struct databuf
typedef databuf<uchar> ucharbuf;
template<class T>
static inline float heapscore(const T &n) { return n; }
struct sortless
{
template<class T> bool operator()(const T &x, const T &y) const { return x < y; }
@ -731,59 +728,6 @@ template <class T> 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<class K>
int htfind(const K &key)
{