WEB开发网
开发学院软件开发C++ HEAP(C语言泛型版) 阅读

HEAP(C语言泛型版)

 2012-05-15 09:48:07 来源:WEB开发网   
核心提示:#include <stdlib.h>#ifndef HEAP_H#define HRAP_Htypedef struct Heap_ { int size; int (*cmp) (const void *, const void *); void (*destroy)(void *);
#include <stdlib.h>

#ifndef HEAP_H
#define HRAP_H

typedef struct Heap_ {
    int size;
    int (*cmp) (const void *, const void *);
    void (*destroy)(void *);

    void **tree;
} Heap;

void heap_init(
            Heap *heap,
            int (*cmp)(const void *, const void *),
            void (*destroy)(void *));

void heap_dealloc(Heap *heap);

int heap_insert(Heap *heap, const void *data);

int heap_extract(Heap *heap, void **data);

#define heap_size(heap) ((heap)->size)


#endif

点击下载此文件

Tags:HEAP

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接