ORIGINAL
Loading...
Searching...
No Matches
original::prique< TYPE, Callback, SERIAL, ALLOC > Class Template Referencefinal

Heap-based priority queue container. More...

#include <prique.h>

Inheritance diagram for original::prique< TYPE, Callback, SERIAL, ALLOC >:
Inheritance graph
Collaboration diagram for original::prique< TYPE, Callback, SERIAL, ALLOC >:
Collaboration graph

Public Member Functions

 prique (const SERIAL< TYPE, ALLOC< TYPE > > &serial=SERIAL< TYPE, ALLOC< TYPE > >{}, const Callback< TYPE > &compare=Callback< TYPE >{})
 Constructs priority queue with container, comparator and allocator.
 
 prique (const std::initializer_list< TYPE > &lst, const Callback< TYPE > &compare=Callback< TYPE >{})
 Constructs from initializer list with comparator and allocator.
 
 prique (const prique &other)
 Copy constructs a priority queue with allocator propagation.
 
priqueoperator= (const prique &other)
 Copy assignment operator.
 
 prique (prique &&other) noexcept
 Move constructs a priority queue with allocator propagation.
 
priqueoperator= (prique &&other) noexcept
 Move assignment operator.
 
void push (const TYPE &e)
 Inserts element maintaining heap property.
 
TYPE pop ()
 Extracts highest priority element.
 
TYPE top () const
 Accesses highest priority element.
 
std::string className () const override
 Gets class name identifier.
 
- Public Member Functions inherited from original::containerAdapter< TYPE, blocksList, allocator >
u_integer size () const override
 Returns the number of elements in the adapter.
 
void clear ()
 Removes all elements from the adapter.
 
bool contains (const TYPE &e) const override
 Checks for element existence in the adapter.
 
integer compareTo (const containerAdapter &other) const override
 Compares two container adapters lexicographically.
 
std::string toString (bool enter) const override
 Generates formatted string representation.
 
 ~containerAdapter () override=default
 Virtual destructor for proper polymorphic cleanup.
 
- Public Member Functions inherited from original::printable
 operator std::string () const
 Explicit conversion to std::string.
 
 operator const char * () const
 Explicit conversion to C-style string.
 
const char * toCString (bool enter) const
 Direct C-string access with formatting control.
 
template<typename TYPE>
auto formatString (const TYPE &t) -> std::string
 
template<typename TYPE>
auto formatCString (const TYPE &t) -> const char *
 
template<typename TYPE>
auto formatEnum (const TYPE &t) -> std::string
 
template<typename TYPE>
auto formatString (TYPE *const &ptr) -> std::string
 
- Public Member Functions inherited from original::container< TYPE, allocator< TYPE > >
bool empty () const
 Checks if the container is empty.
 
virtual ~container ()=default
 Destructor for the container class.
 
- Public Member Functions inherited from original::comparable< containerAdapter< TYPE, blocksList, allocator > >
virtual integer compareTo (const containerAdapter< TYPE, blocksList, allocator > &other) const=0
 Compares the current object with another of the same type.
 
bool operator== (const containerAdapter< TYPE, blocksList, allocator > &other) const
 Checks if the current object is equal to another.
 
bool operator!= (const containerAdapter< TYPE, blocksList, allocator > &other) const
 Checks if the current object is not equal to another.
 
bool operator< (const containerAdapter< TYPE, blocksList, allocator > &other) const
 Checks if the current object is less than another.
 
bool operator> (const containerAdapter< TYPE, blocksList, allocator > &other) const
 Checks if the current object is greater than another.
 
bool operator<= (const containerAdapter< TYPE, blocksList, allocator > &other) const
 Checks if the current object is less than or equal to another.
 
bool operator>= (const containerAdapter< TYPE, blocksList, allocator > &other) const
 Checks if the current object is greater than or equal to another.
 
virtual ~comparable ()=default
 Virtual destructor for proper cleanup of derived objects.
 

Additional Inherited Members

- Static Public Member Functions inherited from original::printable
template<typename TYPE>
static std::string formatString (const TYPE &t)
 Universal value-to-string conversion.
 
template<typename TYPE>
static std::string formatString (TYPE *const &ptr)
 Pointer-specific formatting.
 
template<typename TYPE>
static const char * formatCString (const TYPE &t)
 C-string cache for temporary usage.
 
template<typename TYPE>
static std::string formatEnum (const TYPE &t)
 Enum formatting utility.
 
template<>
auto formatString (const char &t) -> std::string
 
template<>
auto formatString (const bool &t) -> std::string
 
template<>
auto formatString (const char *const &ptr) -> std::string
 
- Protected Member Functions inherited from original::containerAdapter< TYPE, blocksList, allocator >
 containerAdapter (const blocksList< TYPE, allocator< TYPE > > &serial)
 Constructs a container adapter with specified underlying container.
 
- Protected Member Functions inherited from original::container< TYPE, allocator< TYPE > >
 container (allocator< TYPE > alloc=allocator< TYPE >{})
 Constructs a container with specified allocator.
 
TYPE * allocate (u_integer size)
 Allocates raw memory for elements.
 
void deallocate (TYPE *ptr, u_integer size)
 Deallocates memory previously allocated by allocate()
 
void construct (O_TYPE *o_ptr, Args &&... args)
 Constructs an element in-place.
 
void destroy (O_TYPE *o_ptr)
 Destroys an element.
 
- Protected Attributes inherited from original::containerAdapter< TYPE, blocksList, allocator >
blocksList< TYPE, allocator< TYPE > > serial_
 The underlying container instance.
 
- Protected Attributes inherited from original::container< TYPE, allocator< TYPE > >
allocator< TYPE > allocator
 The allocator instance used for memory management.
 

Detailed Description

template<typename TYPE, template< typename > typename Callback = increaseComparator, template< typename, typename > typename SERIAL = blocksList, template< typename > typename ALLOC = allocator>
requires Compare<Callback<TYPE>, TYPE>
class original::prique< TYPE, Callback, SERIAL, ALLOC >

Heap-based priority queue container.

Template Parameters
TYPEType of elements stored in the priority queue
CallbackComparison functor type (default: increaseComparator)
SERIALUnderlying container type (default: blocksList)
ALLOCAllocator template for memory management (default: allocator)

Implements a priority queue using heap algorithms over an underlying container. The element priority is determined by the provided comparator.

The allocator is propagated to both the priority queue and the underlying serial container for consistent memory management of elements.

Note
Template parameters are constrained by:
requires Compare<Callback<TYPE>, TYPE>
Combines Comparable and CallbackOf for comparison callbacks.
Definition types.h:76
Ensures the Callback type provides valid comparison operations for TYPE.
See also
original::containerAdapter for SERIAL container requirements

Constructor & Destructor Documentation

◆ prique() [1/4]

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
original::prique< TYPE, Callback, SERIAL, ALLOC >::prique ( const SERIAL< TYPE, ALLOC< TYPE > > & serial = SERIAL<TYPE, ALLOC<TYPE>>{},
const Callback< TYPE > & compare = Callback<TYPE>{} )
explicit

Constructs priority queue with container, comparator and allocator.

Parameters
serialUnderlying container instance (default: empty)
compareComparison functor instance (default: default-constructed)

Initializes heap structure using algorithms::heapInit. The allocator from the provided container will be used for all memory operations.

◆ prique() [2/4]

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
original::prique< TYPE, Callback, SERIAL, ALLOC >::prique ( const std::initializer_list< TYPE > & lst,
const Callback< TYPE > & compare = Callback<TYPE>{} )

Constructs from initializer list with comparator and allocator.

Parameters
lstElements to initialize the queue
compareComparison functor instance

Uses the default allocator to construct the underlying container and populate it with elements from the initializer list.

◆ prique() [3/4]

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
original::prique< TYPE, Callback, SERIAL, ALLOC >::prique ( const prique< TYPE, Callback, SERIAL, ALLOC > & other)

Copy constructs a priority queue with allocator propagation.

Parameters
otherPriority queue to copy from
Note
The allocator is copied if ALLOC::propagate_on_container_copy_assignment is true

◆ prique() [4/4]

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
original::prique< TYPE, Callback, SERIAL, ALLOC >::prique ( prique< TYPE, Callback, SERIAL, ALLOC > && other)
noexcept

Move constructs a priority queue with allocator propagation.

Parameters
otherQueue to move from
Note
The allocator is moved if ALLOC::propagate_on_container_move_assignment is true
noexcept guarantees exception safety during move

Member Function Documentation

◆ className()

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
auto original::prique< TYPE, Callback, SERIAL, ALLOC >::className ( ) const
nodiscardoverridevirtual

Gets class name identifier.

Returns
"prique" string identifier

Reimplemented from original::containerAdapter< TYPE, blocksList, allocator >.

◆ operator=() [1/2]

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
auto original::prique< TYPE, Callback, SERIAL, ALLOC >::operator= ( const prique< TYPE, Callback, SERIAL, ALLOC > & other)

Copy assignment operator.

Parameters
otherPriority queue to copy from
Returns
Reference to this queue
Note
The allocator is copied if ALLOC::propagate_on_container_copy_assignment is true

◆ operator=() [2/2]

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
auto original::prique< TYPE, Callback, SERIAL, ALLOC >::operator= ( prique< TYPE, Callback, SERIAL, ALLOC > && other)
noexcept

Move assignment operator.

Parameters
otherQueue to move from
Returns
Reference to this queue
Note
noexcept guarantees exception safety during move
The allocator is moved if ALLOC::propagate_on_container_move_assignment is true

◆ pop()

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
auto original::prique< TYPE, Callback, SERIAL, ALLOC >::pop ( )

Extracts highest priority element.

Returns
The extracted element
Exceptions
original::noElementErrorif queue is empty

Uses algorithms::heapAdjustDown after extraction. The element is properly destroyed using the queue's allocator.

◆ push()

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
auto original::prique< TYPE, Callback, SERIAL, ALLOC >::push ( const TYPE & e)

Inserts element maintaining heap property.

Parameters
eElement to insert

Uses algorithms::heapAdjustUp after insertion. The element is constructed using the queue's allocator.

◆ top()

template<typename TYPE, template< typename > typename Callback, template< typename, typename > typename SERIAL, template< typename > typename ALLOC>
requires original::Compare<Callback<TYPE>, TYPE>
auto original::prique< TYPE, Callback, SERIAL, ALLOC >::top ( ) const

Accesses highest priority element.

Returns
Const reference to top element
Precondition
Queue must not be empty

The documentation for this class was generated from the following file: