Skip to content

File binaryheap.c

FileList > base > binaryheap.c

Go to the source code of this file

  • #include <stdlib.h>
  • #include <assert.h>
  • #include "binaryheap.h"
  • #include "memory_alloc.h"
  • #include "error_manager.h"
  • #include "memory_wrapper.hpp"

Public Functions

Type Name
int bh_add (BINARY_HEAP * heap, void * elem)
void bh_build_heap (BINARY_HEAP * heap)
BINARY_HEAP * bh_create (THREAD_ENTRY * thread_p, int max_capacity, int elem_size, bh_key_comparator cmp_func, BH_CMP_ARG cmp_arg)
void bh_destroy (THREAD_ENTRY * thread_p, BINARY_HEAP * heap)
void bh_down_heap (BINARY_HEAP * heap, int index)
void bh_element_at (BINARY_HEAP * heap, int index, void * elem)
bool bh_extract_max (BINARY_HEAP * heap, void * extract_elem)
int bh_insert (BINARY_HEAP * heap, void * elem)
bool bh_is_consistent (BINARY_HEAP * heap)
bool bh_is_full (BINARY_HEAP * heap)
bool bh_peek_max (BINARY_HEAP * heap, void * peek_elem)
bool bh_tests_consistent (BINARY_HEAP * heap)
void bh_to_sorted_array (BINARY_HEAP * heap)
BH_TRY_INSERT_RESULT bh_try_insert (BINARY_HEAP * heap, void * elem, void * replaced)

Public Static Functions

Type Name
void bh_replace_max (BINARY_HEAP * heap, void * elem)
void bh_up_heap (BINARY_HEAP * heap, int index)

Macros

Type Name
define BH_CMP (heap, l, r) (heap-&gt;cmp\_func ([**BH\_ELEMENT**](binaryheap_8h.md#define-bh_element) (heap, l), [**BH\_ELEMENT**](binaryheap_8h.md#define-bh_element) (heap, r), heap-&gt;cmp\_arg))
define BH_ELEMENT_COPY (heap, dest, src) ([**memcpy**](broker__monitor_8c.md#function-timeout) (dest, src, (heap)-&gt;elem\_size))
define BH_LEFT (i) (2\*([**i**](dynamic__load_8c.md#variable-i)) + 1)
define BH_PARENT (i) (([**i**](dynamic__load_8c.md#variable-i) - 1)/2)
define BH_RIGHT (i) (2\*([**i**](dynamic__load_8c.md#variable-i))+2)
define BH_SWAP (heap, left, right) /* multi line expression */

Public Functions Documentation

function bh_add

int bh_add (
    BINARY_HEAP * heap,
    void * elem
) 

function bh_build_heap

void bh_build_heap (
    BINARY_HEAP * heap
) 

function bh_create

BINARY_HEAP * bh_create (
    THREAD_ENTRY * thread_p,
    int max_capacity,
    int elem_size,
    bh_key_comparator cmp_func,
    BH_CMP_ARG cmp_arg
) 

function bh_destroy

void bh_destroy (
    THREAD_ENTRY * thread_p,
    BINARY_HEAP * heap
) 

function bh_down_heap

void bh_down_heap (
    BINARY_HEAP * heap,
    int index
) 

function bh_element_at

void bh_element_at (
    BINARY_HEAP * heap,
    int index,
    void * elem
) 

function bh_extract_max

bool bh_extract_max (
    BINARY_HEAP * heap,
    void * extract_elem
) 

function bh_insert

int bh_insert (
    BINARY_HEAP * heap,
    void * elem
) 

function bh_is_consistent

bool bh_is_consistent (
    BINARY_HEAP * heap
) 

function bh_is_full

bool bh_is_full (
    BINARY_HEAP * heap
) 

function bh_peek_max

bool bh_peek_max (
    BINARY_HEAP * heap,
    void * peek_elem
) 

function bh_tests_consistent

bool bh_tests_consistent (
    BINARY_HEAP * heap
) 

function bh_to_sorted_array

void bh_to_sorted_array (
    BINARY_HEAP * heap
) 

function bh_try_insert

BH_TRY_INSERT_RESULT bh_try_insert (
    BINARY_HEAP * heap,
    void * elem,
    void * replaced
) 

Public Static Functions Documentation

function bh_replace_max

static void bh_replace_max (
    BINARY_HEAP * heap,
    void * elem
) 

function bh_up_heap

static void bh_up_heap (
    BINARY_HEAP * heap,
    int index
) 

Macro Definition Documentation

define BH_CMP

#define BH_CMP (
    heap,
    l,
    r
) `(heap->cmp_func ( BH_ELEMENT (heap, l), BH_ELEMENT (heap, r), heap->cmp_arg))`

define BH_ELEMENT_COPY

#define BH_ELEMENT_COPY (
    heap,
    dest,
    src
) `( memcpy (dest, src, (heap)->elem_size))`

define BH_LEFT

#define BH_LEFT (
    i
) `(2*( i ) + 1)`

define BH_PARENT

#define BH_PARENT (
    i
) `(( i - 1)/2)`

define BH_RIGHT

#define BH_RIGHT (
    i
) `(2*( i )+2)`

define BH_SWAP

#define BH_SWAP (
    heap,
    left,
    right
) `/* multi line expression */`


The documentation for this class was generated from the following file cubrid/src/base/binaryheap.c