18 #ifndef __UT_PriorityQueue_h__
19 #define __UT_PriorityQueue_h__
25 template <
class utPtr,
class utCompare=std::less<utPtr>,
26 bool need_changed_position=false>
32 const utCompare &
compare = utCompare())
41 need_changed_position> &
a)
50 if (need_changed_position)
68 void remove(
unsigned int entry)
73 if (need_changed_position)
94 int64 mem = inclusive ?
sizeof(*this) : 0;
121 unsigned int l = leftChild(entry);
122 unsigned int r = l+1;
123 unsigned int newplace;
142 else if(nodeExists(l))
153 swap(entry, newplace);
163 int nextentry = parent(entry);
167 swap(entry, nextentry);
179 static unsigned int parent(
unsigned int node)
184 static unsigned int leftChild(
unsigned int node)
186 return (node<<1) + 1;
189 static unsigned int rightChild(
unsigned int node)
191 return (node<<1) + 2;
194 bool nodeExists(
unsigned int node)
199 void swap(
unsigned int a,
unsigned int b)
205 if (need_changed_position)
224 template <
typename T>
232 QEntry(
T node,
float d)
241 return myDistance > b.myDistance;
247 bool operator()(
const QEntry &
a,
const QEntry &
b)
const
255 myQueue.
insert(QEntry(node, d));
const utPtr & getEntry(int idx) const
void remove(unsigned int entry)
int64 getMemoryUsage(bool inclusive) const
int64 getMemoryUsage(bool inclusive=false) const
GLboolean GLboolean GLboolean GLboolean a
virtual void changedPosition(utPtr, unsigned int) const
UT_Array< utPtr > myArray
unsigned int append(utPtr t)
void setSize(exint newsize)
CompareResults OIIO_API compare(const ImageBuf &A, const ImageBuf &B, float failthresh, float warnthresh, ROI roi={}, int nthreads=0)
virtual ~UT_PriorityQueue()
UT_PriorityQueue(const UT_PriorityQueue< utPtr, utCompare, need_changed_position > &a)
bool pullOff(T &node, float &d)
bool operator<(const GU_TetrahedronFacet &a, const GU_TetrahedronFacet &b)
GLboolean GLboolean GLboolean b
unsigned int bubbleUp(unsigned int entry)
unsigned int bubbleDown(unsigned int entry)
const utPtr & head() const
UT_PriorityQueue(unsigned int sz=0, const utCompare &compare=utCompare())
Trivial constructor and destructor:
void destroy(unsigned int entry)
calls remove before destroying
void clear()
Resets list to an empty list.
unsigned int insert(utPtr t)
const utCompare comparator
void insert(T node, float d)
bool isEmpty() const
Returns true iff there are no occupied elements in the array.