41 void swap(
unsigned int i,
unsigned int j)
override;
45 void insert(
T*
we,
float v);
47 void update(
T*
we,
float nv);
50 int remove(
T*
we)
override;
56 inline int parent(
int i)
const
61 inline int left(
int i)
const
66 inline int right(
int i)
const
113 if (
we->heapPosition != -1) {
132 if (
we->heapPosition == -1) {
151 const int i =
we->heapPosition;
183 const int i =
we->heapPosition;
193 const float ov =
static_cast<float>(
we->value);
212 const int pi = parent(
i);
222template <
class T>
int CSOObjectHeap<T>::downHeap(
int i)
253 for (
i = 0;
i <
n; ++
i) {
257 n =
newheap->CSOObjectVector<T>::num();
258 for (
i = 0;
i <
n; ++
i) {
259 insert(
newheap->CSOObjectVector<T>::at(
i));
Heap structure with property i>2*i+1 and i>2*i+2.
T * root() const
Returns the root (first) element of heap that is typecast from CSOLiveWireNode to T.
void insert(T *we)
Inserts heap element and resorts the heap.
int remove(T *we) override
Removes the heap element, and resorts the heap.
void swap(unsigned int i, unsigned int j) override
Swaps two heap elements and resorts the heap.
void sort()
Sorts the heap.
~CSOObjectHeap() override
Standard destructor.
void update(T *we, float nv)
Updates the specified heap element with the new value, and resorts the heap.
Dynamic templated vector.
unsigned int num() const
Returns the number of elements in the vector.
virtual void swap(unsigned int p1, unsigned int p2)
Swaps two elements in the vector.
T * firstBoundsCheck() const
Returns the first element, and return nullptr if out of range.
T * at(unsigned int pos) const
Returns the element at the specified position.
virtual void deleteLast()
Deletes the last element of the vector.
virtual unsigned int appendUnsafe(T *elem)
Appends the element to back of vector.
virtual void clear()
Clears all internal pointers.
T * last() const
Returns the last element.
Target mlrange_cast(Source arg)
Generic version of checked ML casts.