54 template<
class X,
class INDEX =
int>
64 bool empty()
const {
return num == 0; }
72 const X&
top()
const {
116 while( (papa = idx/2) > 0) {
117 if( data[papa] > data[idx] ) {
118 data.
swap(papa, idx);
128 if( (son = 2*papa) < num && data[son+1] < data[son] )
130 if( son <= num && data[son] < data[papa]) {
131 data.
swap(papa, son);
147 template<
class X,
class INDEX =
int>
193 return PushResult::Rejected;
196 ret = PushResult::Swapped;
242 template<
class X,
class Priority=
double,
class STATICCOMPARER=StdComparer<X>,
class INDEX =
int >
284 pushAndDeleteNoRedundancy(p, x);
static bool returnedSomething(PushResult r)
Convenience function: Returns true if the PushResults states that push caused an element to be not/no...
void push(X &x)
Adds an element to the heap [Same as insert(), O(log n)].
const X & getMin() const
Returns a reference to the top (i.e., smallest) element of the heap. It does not remove it...
Declarations for Comparer objects.
A static comparer which compares the target of pointers ("content"), instead of the pointer's adresse...
void swap(INDEX i, INDEX j)
Swaps the elements at position i and j.
PushResult
The type for results of a Top10Heap::push operation.
A variant of BinaryHeapSimple which always holds only the X (e.g. X=10) elements with the highest key...
void insertAndDeleteNoRedundancy(X *x, Priority p)
Alternative name for pushAndKillNoRedundancy().
void pushAndDeleteNoRedundancy(X *x, Priority p)
Analogous to pushandDelete(), but furthermore rejects (and deletes) an element if an equal element is...
Declaration and implementation of Array class and Array algorithms.
Augments any data elements of type X with keys of type Priority. This class is also its own Comparer...
Dynamically growing binary heap tuned for efficiency on a small interface (compared to BinaryHeap)...
void insertBlind(X &x)
Alternative name for pushBlind().
PushResult push(X &x, X &out)
Tries to push the element x onto the heap (and may return a removed element as out).
void insertAndDelete(X *x, Priority p)
Alternative name for pushAndDelete().
const X & operator[](INDEX idx) const
obtain const references to the element at index idx (the smallest array index is 0, as for traditional C-arrays)
INDEX size() const
Returns the number of elements in the heap.
const X & top() const
Returns a reference to the top (i.e., smallest) element of the heap. It does not remove it...
bool full() const
Returns true if the heap is completely filled (i.e. the next push operation will return something) ...
INDEX size() const
Returns the size (number of elements) of the array.
PushResult insert(X &x, X &out)
Alternative name for push().
BinaryHeapSimple(INDEX size)
Construtor, giving initial array size.
X item() const
Returns the data of the element.
void grow(INDEX add, const E &x)
Enlarges the array by add elements and sets new elements to x.
bool empty() const
Returns true if the heap is empty.
void insert(X &x)
Adds an element to the heap [Same as push(), O(log n)].
void pushBlind(X &x)
Simple (and slightly faster) variant of Top10Heap::push.
Top10Heap()
Constructor generating a heap which holds the 10 elements with highest value ever added to the heap...
INDEX capacity() const
Returns the current array-size of the heap, i.e., the number of elements which can be added before th...
A variant of Top10Heap which deletes the elements that get rejected from the heap.
static bool successful(PushResult r)
Convenience function: Returns true if the PushResults states that the newly pushed element is new in ...
void pushAndDelete(X *x, Priority p)
Inserts the element x into the heap with priority p and deletes the element with smallest priority if...
X pop()
Returns the top (i.e., smallest) element and removed it from the heap [Same as extractMin(), O(log n)].
void clear()
empties the heap [O(1)]
The namespace for all OGDF objects.
X extractMin()
Returns the top (i.e., smallest) element and removed it from the heap [Same as pop(), O(log n)].
const X & operator[](INDEX idx) const
obtain const references to the element at index idx
#define OGDF_ASSERT(expr)
Assert condition expr. See doc/build.md for more information.
DeletingTop10Heap(int size)
Construct a DeletingTop10Heap of given maximal capacity.