[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r33172 - in gnunet/src: include util
From: |
gnunet |
Subject: |
[GNUnet-SVN] r33172 - in gnunet/src: include util |
Date: |
Tue, 6 May 2014 12:26:21 +0200 |
Author: tg
Date: 2014-05-06 12:26:21 +0200 (Tue, 06 May 2014)
New Revision: 33172
Modified:
gnunet/src/include/gnunet_container_lib.h
gnunet/src/util/container_heap.c
Log:
add GNUNET_CONTAINER_heap_peek2()
Modified: gnunet/src/include/gnunet_container_lib.h
===================================================================
--- gnunet/src/include/gnunet_container_lib.h 2014-05-06 10:26:14 UTC (rev
33171)
+++ gnunet/src/include/gnunet_container_lib.h 2014-05-06 10:26:21 UTC (rev
33172)
@@ -1670,16 +1670,31 @@
/**
* @ingroup heap
- * Get element stored at root of heap.
+ * Get element stored at the root of @a heap.
*
- * @param heap heap to inspect
- * @return NULL if heap is empty
+ * @param heap Heap to inspect.
+ * @return Element at the root, or NULL if heap is empty.
*/
void *
GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap);
/**
+ * Get @a element and @a cost stored at the root of @a heap.
+ *
+ * @param[in] heap Heap to inspect.
+ * @param[out] element Root element is returned here.
+ * @param[out] cost Cost of @a element is returned here.
+ * @return #GNUNET_YES if an element is returned,
+ * #GNUNET_NO if the heap is empty.
+ */
+int
+GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap,
+ void **element,
+ GNUNET_CONTAINER_HeapCostType *cost);
+
+
+/**
* @ingroup heap
* Get the current size of the heap
*
Modified: gnunet/src/util/container_heap.c
===================================================================
--- gnunet/src/util/container_heap.c 2014-05-06 10:26:14 UTC (rev 33171)
+++ gnunet/src/util/container_heap.c 2014-05-06 10:26:21 UTC (rev 33172)
@@ -163,10 +163,10 @@
/**
- * Get element stored at root of heap.
+ * Get element stored at the root of @a heap.
*
- * @param heap heap to inspect
- * @return NULL if heap is empty
+ * @param heap Heap to inspect.
+ * @return Element at the root, or NULL if heap is empty.
*/
void *
GNUNET_CONTAINER_heap_peek (const struct GNUNET_CONTAINER_Heap *heap)
@@ -178,6 +178,30 @@
/**
+ * Get @a element and @a cost stored at the root of @a heap.
+ *
+ * @param[in] heap Heap to inspect.
+ * @param[out] element Root element is returned here.
+ * @param[out] cost Cost of @a element is returned here.
+ * @return #GNUNET_YES if an element is returned,
+ * #GNUNET_NO if the heap is empty.
+ */
+int
+GNUNET_CONTAINER_heap_peek2 (const struct GNUNET_CONTAINER_Heap *heap,
+ void **element,
+ GNUNET_CONTAINER_HeapCostType *cost)
+{
+ if (NULL == heap->root)
+ return GNUNET_NO;
+ if (NULL != element)
+ *element = heap->root->element;
+ if (NULL != cost)
+ *cost = heap->root->cost;
+ return GNUNET_YES;
+}
+
+
+/**
* Get the current size of the heap
*
* @param heap the heap to get the size of
@@ -203,6 +227,7 @@
return node->cost;
}
+
/**
* Iterate over the children of the given node.
*
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r33172 - in gnunet/src: include util,
gnunet <=