Browse Source

[Minor] Add rspamd_min_heap_index helper method

tags/1.2.3
Vsevolod Stakhov 8 years ago
parent
commit
db6676684a
2 changed files with 18 additions and 0 deletions
  1. 9
    0
      src/libutil/heap.c
  2. 9
    0
      src/libutil/heap.h

+ 9
- 0
src/libutil/heap.c View File

@@ -179,3 +179,12 @@ rspamd_min_heap_destroy (struct rspamd_min_heap *heap)
g_slice_free1 (sizeof (*heap), heap);
}
}

struct rspamd_min_heap_elt*
rspamd_min_heap_index (struct rspamd_min_heap *heap, guint idx)
{
g_assert (heap != NULL);
g_assert (idx >= 0 && idx < heap->ar->len);

return g_ptr_array_index (heap->ar, idx);
}

+ 9
- 0
src/libutil/heap.h View File

@@ -77,4 +77,13 @@ void rspamd_min_heap_remove_elt (struct rspamd_min_heap *heap,
*/
void rspamd_min_heap_destroy (struct rspamd_min_heap *heap);

/**
* Returns element from the heap with the specified index
* @param heap
* @param idx
* @return
*/
struct rspamd_min_heap_elt* rspamd_min_heap_index (struct rspamd_min_heap *heap,
guint idx);

#endif /* SRC_LIBUTIL_HEAP_H_ */

Loading…
Cancel
Save