32 #include <initializer_list> 40 #define GUM_HEAP_DEFAULT_CAPACITY 10 44 template <
typename Val,
typename Cmp,
typename Alloc >
46 template <
typename Val,
typename Cmp,
typename Alloc >
47 std::ostream& operator<<(std::ostream&, const Heap< Val, Cmp, Alloc >&);
118 template <
typename Val,
119 typename Cmp = std::less< Val >,
120 typename Alloc = std::allocator< Val > >
154 explicit Heap(std::initializer_list< Val > list);
167 template <
typename OtherAlloc >
210 template <
typename OtherAlloc >
246 const Val&
top()
const;
291 void erase(
const Val& val);
318 template <
typename... Args >
331 bool empty() const noexcept;
386 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 387 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 388 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 393 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 394 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 395 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 401 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 402 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 403 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS bool contains(const Val &) const
Indicates whether the heap contains a given value.
Val & reference
Types for STL compliance.
Size __nb_elements
The number of elements in the heap.
bool empty() const noexcept
Indicates whether the heap is empty.
Heap(Cmp compare=Cmp(), Size capacity=GUM_HEAP_DEFAULT_CAPACITY)
Basic constructor: creates an empty heap.
#define GUM_HEAP_DEFAULT_CAPACITY
const Val & operator[](Size index_elt) const
Returns the element at index index_elt from the heap.
std::ptrdiff_t difference_type
Types for STL compliance.
Val pop()
Removes the top element from the heap and return it.
std::size_t size_type
Types for STL compliance.
const Val & const_reference
Types for STL compliance.
gum is the global namespace for all aGrUM entities
Size emplace(Args &&... args)
Emplace a new element in the heap and returns its index.
template implementations of heaps
const Val * const_pointer
Types for STL compliance.
Cmp __cmp
Comparison function.
void erase(const Val &val)
Removes a given element from the heap (but does not return it).
std::string toString() const
Size size() const noexcept
Returns the number of elements in the heap.
std::vector< Val, Alloc > __heap
An array storing all the elements of the heap.
Val * pointer
Types for STL compliance.
Size __restoreHeap()
After inserting an element at the end of the heap, restore heap property.
Val value_type
Types for STL compliance.
Size insert(const Val &val)
inserts a new element (actually a copy) in the heap and returns its index
void eraseTop()
Removes the top of the heap (but does not return it).
Heap< Val, Cmp, Alloc > & operator=(const Heap< Val, Cmp, Alloc > &from)
Copy operator.
Size capacity() const noexcept
Returns the size of the internal structure storing the heap.
Heap data structureThis structure is a basic heap data structure, i.e., it is a container in which el...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
void resize(Size new_size)
Changes the size of the the internal structure storing the heap.
void eraseByPos(Size index)
Removes the element positioned at "index" from the heap.
Alloc allocator_type
Types for STL compliance.
const Val & top() const
Returns the element at the top of the heap.