[c5c522c] | 1 | /* $Id: heap.h,v 1.10 2011/06/28 00:13:48 sbajic Exp $ */ |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | DSPAM |
---|
| 5 | COPYRIGHT (C) 2002-2012 DSPAM PROJECT |
---|
| 6 | |
---|
| 7 | This program is free software: you can redistribute it and/or modify |
---|
| 8 | it under the terms of the GNU Affero General Public License as |
---|
| 9 | published by the Free Software Foundation, either version 3 of the |
---|
| 10 | License, or (at your option) any later version. |
---|
| 11 | |
---|
| 12 | This program is distributed in the hope that it will be useful, |
---|
| 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 15 | GNU Affero General Public License for more details. |
---|
| 16 | |
---|
| 17 | You should have received a copy of the GNU Affero General Public License |
---|
| 18 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
---|
| 19 | |
---|
| 20 | */ |
---|
| 21 | |
---|
| 22 | #ifndef _HEAP_H |
---|
| 23 | #define _HEAP_H |
---|
| 24 | |
---|
| 25 | #define HP_DELTA 0x00 |
---|
| 26 | #define HP_VALUE 0x01 |
---|
| 27 | |
---|
| 28 | typedef struct _ds_heap |
---|
| 29 | { |
---|
| 30 | unsigned int items; |
---|
| 31 | unsigned int size; |
---|
| 32 | char type; |
---|
| 33 | struct _ds_heap_element *root; |
---|
| 34 | } *ds_heap_t; |
---|
| 35 | |
---|
| 36 | typedef struct _ds_heap_element |
---|
| 37 | { |
---|
| 38 | double delta; |
---|
| 39 | float probability; |
---|
| 40 | unsigned long long token; |
---|
| 41 | unsigned long frequency; |
---|
| 42 | int complexity; |
---|
| 43 | struct _ds_heap_element *next; |
---|
| 44 | } *ds_heap_element_t; |
---|
| 45 | |
---|
| 46 | ds_heap_t ds_heap_create (int size, int type); |
---|
| 47 | void ds_heap_destroy (ds_heap_t); |
---|
| 48 | |
---|
| 49 | ds_heap_element_t ds_heap_element_create (double probability, |
---|
| 50 | unsigned long long token, unsigned long frequency, int complexity); |
---|
| 51 | |
---|
| 52 | ds_heap_element_t ds_heap_insert (ds_heap_t h, double probability, |
---|
| 53 | unsigned long long token, unsigned long frequency, int complexity); |
---|
| 54 | |
---|
| 55 | #endif /* _HEAP_H */ |
---|