Easy3D 2.5.3
Heap< HeapEntry, HeapInterface > Class Template Reference

A class implementing a heap. More...

#include <easy3d/core/heap.h>

Inheritance diagram for Heap< HeapEntry, HeapInterface >:

Public Types

typedef Heap< HeapEntry, HeapInterface > This
 

Public Member Functions

 Heap ()
 Constructor.
 
 Heap (const HeapInterface &i)
 Construct with a given HeapInterface.
 
 ~Heap ()=default
 Destructor.
 
void clear ()
 clear the heap
 
bool empty ()
 is heap empty?
 
unsigned int size ()
 returns the size of heap
 
void reserve (unsigned int n)
 reserve space for N entries
 
void reset_heap_position (HeapEntry h)
 reset heap position to -1 (not in heap)
 
bool is_stored (HeapEntry h)
 is an entry in the heap?
 
void insert (HeapEntry h)
 insert the entry h
 
HeapEntry front ()
 get the first entry
 
void pop_front ()
 delete the first entry
 
void remove (HeapEntry h)
 remove an entry
 
void update (HeapEntry h)
 update an entry: change the key and update the position to reestablish the heap property.
 
bool check ()
 check heap condition
 

Detailed Description

template<class HeapEntry, class HeapInterface>
class easy3d::Heap< HeapEntry, HeapInterface >

A class implementing a heap.

An example of heap interface

class HeapInterface {
public:
HeapInterface(SurfaceMesh::VertexProperty<float> prio, SurfaceMesh::VertexProperty<int> pos)
: prio_(prio), pos_(pos) {
}
bool less(SurfaceMesh::Vertex v0, SurfaceMesh::Vertex v1) { return prio_[v0] < prio_[v1]; }
bool greater(SurfaceMesh::Vertex v0, SurfaceMesh::Vertex v1) { return prio_[v0] > prio_[v1]; }
int get_heap_position(SurfaceMesh::Vertex v) { return pos_[v]; }
void set_heap_position(SurfaceMesh::Vertex v, int pos) { pos_[v] = pos; }
private:
SurfaceMesh::VertexProperty<float> prio_;
SurfaceMesh::VertexProperty<int> pos_;
};

The documentation for this class was generated from the following file: