Home

Awesome

Binary heap - type agnostic

(c) 2012-2016 Daniele Lacamera root@danielinux.net

Introduction

This is a preprocessor-only implementation of a type agnostic binary heap data structure. Inserting ordered elements is O(logN), peeking the first element is O(1).

For its properties, this data structure is indicated to implement timers.

Usage

        typedef struct potato {
            /* some fields ... */
            uint32_t weight;    /* Field used for sorting */
            /* more fields ... */
        } potato_t; 

DECLARE_HEAP(potato_t, weight);

heap_potato_t *pHeap = heap_init();

License

See COPYING.