Files
cKit/Sort/c_MaxPQ.h
T

35 lines
1.2 KiB
C
Raw Normal View History

2026-08-29 01:58:00 +08:00
#ifndef INCLUDED_C_MAXPQ_H
#define INCLUDED_C_MAXPQ_H
#ifndef INCLUDED_C_TYPES_H
#include <c_Types.h>
#endif /*INCLUDED_C_TYPES_H*/
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
typedef struct {
void* data; // Flat char pointer block tracking memory slots
c_size_t element_size; // Size of each complex structure element in bytes
c_size_t capacity; // Maximum allocated element capacity
c_size_t size; // Current active element count inside the heap
int (*compar)(const void*, const void*); // Custom comparison rule pointer
} c_MaxPQ_t;
/* ------------------------------------------------------------------------------------------------------------------ */
/* */
c_err_t c_MaxPQ_Init(c_MaxPQ_t* pq, c_size_t initial_capacity, c_size_t element_size,
int (*compar)(const void*, const void*));
void c_MaxPQ_Destroy(c_MaxPQ_t* pq);
c_err_t c_MaxPQ_Push(c_MaxPQ_t* pq, const void* element);
c_err_t c_MaxPQ_Pop(c_MaxPQ_t* pq, void* output_buffer);
void* c_MaxPQ_Peek(c_MaxPQ_t* pq);
c_err_t c_MaxPQ_Clear(c_MaxPQ_t* pq);
c_err_t c_MaxPQ_Resize(c_MaxPQ_t* pq, c_size_t new_capacity);
#endif /*INCLUDED_C_MAXPQ_H*/