35 #include <initializer_list> 43 #define GUM_HEAP_DEFAULT_CAPACITY 10 47 template <
typename Val,
typename Cmp,
typename Alloc >
49 template <
typename Val,
typename Cmp,
typename Alloc >
50 std::ostream& operator<<(std::ostream&, const Heap< Val, Cmp, Alloc >&);
121 template <
typename Val,
122 typename Cmp = std::less< Val >,
123 typename Alloc = std::allocator< Val > >
157 explicit Heap(std::initializer_list< Val > list);
170 template <
typename OtherAlloc >
213 template <
typename OtherAlloc >
249 const Val&
top()
const;
294 void erase(
const Val& val);
321 template <
typename... Args >
334 bool empty() const noexcept;
389 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 390 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 391 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 396 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 397 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 398 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 404 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 405 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 406 # 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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size emplace(Args &&... args)
Emplace a new element in the heap and returns its index.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.