gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r8368 - GNUnet/src/include


From: gnunet
Subject: [GNUnet-SVN] r8368 - GNUnet/src/include
Date: Tue, 31 Mar 2009 19:08:08 -0600

Author: nevans
Date: 2009-03-31 19:08:08 -0600 (Tue, 31 Mar 2009)
New Revision: 8368

Removed:
   GNUnet/src/include/gnunet_dv_lib.h
Modified:
   GNUnet/src/include/gnunet_util_containers.h
Log:
heap methods into util_containers.h

Deleted: GNUnet/src/include/gnunet_dv_lib.h
===================================================================
--- GNUnet/src/include/gnunet_dv_lib.h  2009-04-01 01:05:58 UTC (rev 8367)
+++ GNUnet/src/include/gnunet_dv_lib.h  2009-04-01 01:08:08 UTC (rev 8368)
@@ -1,55 +0,0 @@
-/*
-     This file is part of GNUnet.
-     (C) 2008 Christian Grothoff (and other contributing authors)
-
-     GNUnet is free software; you can redistribute it and/or modify
-     it under the terms of the GNU General Public License as published
-     by the Free Software Foundation; either version 2, or (at your
-     option) any later version.
-
-     GNUnet is distributed in the hope that it will be useful, but
-     WITHOUT ANY WARRANTY; without even the implied warranty of
-     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-     General Public License for more details.
-
-     You should have received a copy of the GNU General Public License
-     along with GNUnet; see the file COPYING.  If not, write to the
-     Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-     Boston, MA 02111-1307, USA.
-*/
-
-/**
- * @author Nathan Evans
- * @file include/gnunet_dv_lib.h
- * @brief Provides access to applications wishing to use the fisheye
- * distance vector routing algorithm.
- */
-#ifndef GNUNET_DV_LIB_H
-#define GNUNET_DV_LIB_H
-
-#include "gnunet_core.h"
-
-/*
- * Provides handler for sending a message via the dv module
- *
- * @recipient for which peer the message is intended
- * @message the message being sent
- */
-int GNUNET_DV_send_message (const GNUNET_PeerIdentity * recipient,
-                            const GNUNET_MessageHeader * message,
-                            unsigned int importance, unsigned int maxdelay);
-
-/**
- * Calls a given method for each dv connected host.
- *
- * @param method method to call for each connected peer
- * @param arg second argument to method
- * @return number of connected nodes
- */
-int
-GNUNET_DV_connection_iterate_peers (GNUNET_NodeIteratorCallback method,
-                                    void *arg);
-
-#endif
-
-/* end of gnunet_dv_lib.h */

Modified: GNUnet/src/include/gnunet_util_containers.h
===================================================================
--- GNUnet/src/include/gnunet_util_containers.h 2009-04-01 01:05:58 UTC (rev 
8367)
+++ GNUnet/src/include/gnunet_util_containers.h 2009-04-01 01:08:08 UTC (rev 
8368)
@@ -578,9 +578,108 @@
     (element)->next->prev = (element)->prev;
 
 
+typedef unsigned int GNUNET_CostType;
 
+/*
+ * Heap type, either max or min.  Hopefully makes the
+ * implementation more useful.
+ */
+typedef enum
+{
+  GNUNET_MAX_HEAP = 0,
+  GNUNET_MIN_HEAP = 1,
+} GNUNET_CONTAINER_HeapType;
 
+/*
+ * Struct that is stored in hashmap, pointers to
+ * locations in min_heap and max_heap.
+ */
+struct GNUNET_CONTAINER_Heap;
 
+struct GNUNET_CONTAINER_Heap
+  *GNUNET_CONTAINER_heap_create (GNUNET_CONTAINER_HeapType type);
+
+void GNUNET_CONTAINER_heap_destroy (struct GNUNET_CONTAINER_Heap *h);
+
+/**
+ * Iterator for heap
+ *
+ * @param value - obj stored in heap
+ * @param root - root of heap in which obj is stored
+ * @param cls - client arg passed through
+ * @return GNUNET_YES if we should continue to
+ *         iterate,
+ *         GNUNET_NO if not.
+ */
+typedef int (*GNUNET_CONTAINER_HeapIterator) (void *element,
+                                              GNUNET_CostType cost,
+                                              struct GNUNET_CONTAINER_Heap *
+                                              root, void *cls);
+
+/**
+ * Iterate over all entries in the map.
+ *
+ * @param heap - the heap
+ * @param iterator - function to call on each entry
+ * @param cls - client argument (closure)
+ * @return - number of items handled
+ *         GNUNET_SYSERR if there's a problem
+ */
+int GNUNET_CONTAINER_heap_iterate (struct GNUNET_CONTAINER_Heap *heap,
+                                   GNUNET_CONTAINER_HeapIterator iterator,
+                                   void *cls);
+
+
+/**
+ * Inserts a new item into the heap, item is always neighbor now.
+ */
+int
+GNUNET_CONTAINER_heap_insert (struct GNUNET_CONTAINER_Heap *root,
+                              void *element, GNUNET_CostType cost);
+
+/**
+ * Removes root of the tree, is remove max if a max heap and remove min
+ * if a min heap, returns the data stored at the node.
+ */
+void *GNUNET_CONTAINER_heap_remove_root (struct GNUNET_CONTAINER_Heap *root);
+
+/**
+ * Returns data stored at root of tree, doesn't effect anything
+ */
+void *GNUNET_CONTAINER_heap_peek (struct GNUNET_CONTAINER_Heap *root);
+
+/**
+ * Removes any node from the tree based on the neighbor given, does
+ * not traverse the tree (backpointers) but may take more time due to
+ * percolation of nodes.
+ */
+void *GNUNET_CONTAINER_heap_remove_node (struct GNUNET_CONTAINER_Heap *root,
+                                         void *element);
+
+/**
+ * Updates the cost of any node in the tree
+ */
+int
+GNUNET_CONTAINER_heap_update_cost (struct GNUNET_CONTAINER_Heap *root,
+                                   void *element, GNUNET_CostType new_cost);
+
+/**
+ * Random walk of the tree, returns the data stored at the next random node
+ * in the walk.  Calls callee with the data, or NULL if the tree is empty
+ * or some other problem crops up.
+ */
+void *GNUNET_CONTAINER_heap_walk_get_next (struct GNUNET_CONTAINER_Heap
+                                           *root);
+
+/*
+ * Returns the current size of the heap
+ *
+ * @param heap the heap to get the size of
+ */
+unsigned int
+GNUNET_CONTAINER_heap_get_size (struct GNUNET_CONTAINER_Heap *heap);
+
+
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif





reply via email to

[Prev in Thread] Current Thread [Next in Thread]