diff options
author | Nick Mathewson <nickm@torproject.org> | 2009-12-10 11:57:30 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2009-12-12 19:06:38 -0500 |
commit | c210db0d41f4a47496e12c0af829f8ae0a5c2cd2 (patch) | |
tree | c0000252ac688c6e9525206b4aa906088f4b902d /src/common/container.h | |
parent | d086c9a7f73ce5b9b7cf4add07fa7d071b829081 (diff) | |
download | tor-c210db0d41f4a47496e12c0af829f8ae0a5c2cd2.tar.gz tor-c210db0d41f4a47496e12c0af829f8ae0a5c2cd2.zip |
Enhance pqueue so we can remove items from the middle.
This changes the pqueue API by requiring an additional int in every
structure that we store in a pqueue to hold the index of that structure
within the heap.
Diffstat (limited to 'src/common/container.h')
-rw-r--r-- | src/common/container.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/common/container.h b/src/common/container.h index 41c0c68705..8077d56ebd 100644 --- a/src/common/container.h +++ b/src/common/container.h @@ -118,11 +118,18 @@ int smartlist_bsearch_idx(const smartlist_t *sl, const void *key, void smartlist_pqueue_add(smartlist_t *sl, int (*compare)(const void *a, const void *b), + int idx_field_offset, void *item); void *smartlist_pqueue_pop(smartlist_t *sl, - int (*compare)(const void *a, const void *b)); + int (*compare)(const void *a, const void *b), + int idx_field_offset); +void smartlist_pqueue_remove(smartlist_t *sl, + int (*compare)(const void *a, const void *b), + int idx_field_offset, + void *item); void smartlist_pqueue_assert_ok(smartlist_t *sl, - int (*compare)(const void *a, const void *b)); + int (*compare)(const void *a, const void *b), + int idx_field_offset); #define SPLIT_SKIP_SPACE 0x01 #define SPLIT_IGNORE_BLANK 0x02 |