41 void swap(
unsigned int i,
unsigned int j)
override;
62 inline int left(
int i)
const
67 inline int right(
int i)
const
97 return reinterpret_cast<T*
>(
wp);
116 at(
i)->setHeapPosition(
i);
117 at(
j)->setHeapPosition(
j);
127 if (
wp->getHeapPosition() != -1) {
132 const unsigned int n = num() - 1;
133 last()->setHeapPosition(
n);
145 if (
wp->getHeapPosition() == -1) {
148 const unsigned int n = num() - 1;
149 last()->setHeapPosition(
n);
165 const int i =
wp->getHeapPosition();
177 wp->setHeapPosition(-1);
187 wp->setHeapPosition(-1);
197 const int i =
wp->getHeapPosition();
207 const double ov =
wp->getHeapValue();
209 wp->setHeapValue(
nv);
226 const int pi = parent(
i);
236template <
class T>
int WEMHeap<T>::downHeap(
int i)
266 const unsigned int n = num();
267 for (
i = 0;
i <
n;
i++) {
272 for (
i = 0;
i <
nn;
i++) {
283 const unsigned int n = num();
284 for (
unsigned int i = 0;
i <
n;
i++) {
285 at(
i)->setHeapPosition(-1);
Min-Heap structure with property v[i]<v[2*i+1] and v[i]<v[2*i+2] Parent at index i has children at in...
void update(WEMPrimitive *wp, double nv)
Updates given heap element with the given value and resorts this heap.
void clear() override
Remove all elements from heap.
void sort()
Sorts this heap.
void swap(unsigned int i, unsigned int j) override
Swaps two heap elements given by their indices and resorts this heap.
T * root()
Returns the root (first) element of this heap, typecast from WEMPrimitive to T.
~WEMHeap() override
Standard destructor.
int remove(WEMPrimitive *wp) override
Removes the given heap element and resorts this heap.
WEMHeap(WEMHeap &&) noexcept=default
void insert(WEMPrimitive *wp)
Inserts the given heap element and resorts this heap.
This is the base class for the WEM elements nodes, edges, and faces.
Dynamic templated vector.
virtual void clear()
Clears all internal pointers.
virtual void swap(unsigned int p1, unsigned int p2)
Swaps the two elements given by their indices in this vector.
virtual unsigned int appendUnsafe(T *elem)
Append element to back of vector, don't check on element being non-NULL.
T * first()
Returns the first element.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.
IteratorTraits::value_type & at(const ml_iterator_map< IteratorTraits, IDMap > &i, typename property_traits< IDMap >::key_type key)
static bool less(const WEMPrimitive &x, const WEMPrimitive &y)