44 #ifndef TRISTRIP_HEAP_ARRAY_H 45 #define TRISTRIP_HEAP_ARRAY_H 54 template <
class T,
class CmpT = std::less<T> >
74 bool valid(
size_t i)
const;
76 const T &
top()
const;
77 const T &
peek(
size_t i)
const;
80 size_t push(
const T & Elem);
84 void update(
size_t i,
const T & Elem);
89 linker(
const T & Elem,
size_t i) : m_Elem(Elem), m_Indice(i) { }
99 void Swap(
size_t a,
size_t b);
115 template <
class T,
class CmpT>
123 template <
class T,
class CmpT>
129 template <
class T,
class CmpT>
135 template <
class T,
class CmpT>
142 template <
class T,
class CmpT>
148 template <
class T,
class CmpT>
152 if (
empty())
throw "heap_array<T, CmpT>::top() error, heap empty";
154 return m_Heap.front().m_Elem;
158 template <
class T,
class CmpT>
162 if (
removed(i))
throw "heap_array<T, CmpT>::peek(size_t i) error";
168 template <
class T,
class CmpT>
174 template <
class T,
class CmpT>
180 if (
empty())
throw "heap_array<T, CmpT>::pop() error, heap empty";
188 template <
class T,
class CmpT>
191 throw "heap_is_locked";
202 template <
class T,
class CmpT>
207 if (
removed(i))
throw "heap_array<T, CmpT>::erase(size_t i) error";
226 template <
class T,
class CmpT>
232 template <
class T,
class CmpT>
238 template <
class T,
class CmpT>
242 if (
removed(i))
throw "heap_array<T, CmpT>::update(size_t i, const T & Elem) error";
250 template <
class T,
class CmpT>
253 if (
m_Heap.size()<=1)
return;
258 for (j = i; (j > 0) && (
Less(
m_Heap[(j - 1) / 2],
m_Heap[j])); j = ((j - 1) / 2))
259 Swap(j, (j - 1) / 2);
262 for (i = j; (j = 2 * i + 1) <
size(); i = j) {
274 template <
class T,
class CmpT>
284 template <
class T,
class CmpT>
std::vector< linker > linked_heap
GLboolean GLboolean GLboolean GLboolean a
size_t push(const T &Elem)
linker(const T &Elem, size_t i)
GLboolean GLboolean GLboolean b
void update(size_t i, const T &Elem)
void reserve(size_t Size)
bool valid(size_t i) const
const T & peek(size_t i) const
bool removed(size_t i) const
bool Less(const linker &a, const linker &b) const
void Swap(size_t a, size_t b)
const T & operator[](size_t i) const
std::vector< size_t > finder