changeset 16000:944256db9184 draft

(svn r20688) -Codechange: Rename Queue struct to BinaryHeap.
author alberth <alberth@openttd.org>
date Sun, 29 Aug 2010 13:47:15 +0000
parents a3a3c4ff520f
children 3ea421d91675
files src/pathfinder/npf/aystar.h src/pathfinder/npf/queue.cpp src/pathfinder/npf/queue.h
diffstat 3 files changed, 16 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/pathfinder/npf/aystar.h
+++ b/src/pathfinder/npf/aystar.h
@@ -161,7 +161,7 @@
 	/* The actual closed list */
 	Hash ClosedListHash;
 	/* The open queue */
-	Queue OpenListQueue;
+	BinaryHeap OpenListQueue;
 	/* An extra hash to speed up the process of looking up an element in
 	 * the open list */
 	Hash OpenListHash;
--- a/src/pathfinder/npf/queue.cpp
+++ b/src/pathfinder/npf/queue.cpp
@@ -7,7 +7,7 @@
  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
  */
 
-/** @file queue.cpp Implementation of the Queue/Hash. */
+/** @file queue.cpp Implementation of the #BinaryHeap/#Hash. */
 
 #include "../../stdafx.h"
 #include "../../core/alloc_func.hpp"
@@ -19,16 +19,16 @@
  * For information, see: http://www.policyalmanac.org/games/binaryHeaps.htm
  */
 
-const int Queue::BINARY_HEAP_BLOCKSIZE_BITS = 10; ///< The number of elements that will be malloc'd at a time.
-const int Queue::BINARY_HEAP_BLOCKSIZE      = 1 << Queue::BINARY_HEAP_BLOCKSIZE_BITS;
-const int Queue::BINARY_HEAP_BLOCKSIZE_MASK = Queue::BINARY_HEAP_BLOCKSIZE - 1;
+const int BinaryHeap::BINARY_HEAP_BLOCKSIZE_BITS = 10; ///< The number of elements that will be malloc'd at a time.
+const int BinaryHeap::BINARY_HEAP_BLOCKSIZE      = 1 << BinaryHeap::BINARY_HEAP_BLOCKSIZE_BITS;
+const int BinaryHeap::BINARY_HEAP_BLOCKSIZE_MASK = BinaryHeap::BINARY_HEAP_BLOCKSIZE - 1;
 
 /**
  * Clears the queue, by removing all values from it. Its state is
  * effectively reset. If free_items is true, each of the items cleared
  * in this way are free()'d.
  */
-void Queue::Clear(bool free_values)
+void BinaryHeap::Clear(bool free_values)
 {
 	/* Free all items if needed and free all but the first blocks of memory */
 	uint i;
@@ -65,7 +65,7 @@
  * this it is no longer usable. If free_items is true, any remaining
  * items are free()'d too.
  */
-void Queue::Free(bool free_values)
+void BinaryHeap::Free(bool free_values)
 {
 	uint i;
 
@@ -81,7 +81,7 @@
  * Pushes an element into the queue, at the appropriate place for the queue.
  * Requires the queue pointer to be of an appropriate type, of course.
  */
-bool Queue::Push(void *item, int priority)
+bool BinaryHeap::Push(void *item, int priority)
 {
 #ifdef QUEUE_DEBUG
 	printf("[BinaryHeap] Pushing an element. There are %d elements left\n", this->size);
@@ -137,7 +137,7 @@
  * known, which speeds up the deleting for some queue's. Should be -1
  * if not known.
  */
-bool Queue::Delete(void *item, int priority)
+bool BinaryHeap::Delete(void *item, int priority)
 {
 	uint i = 0;
 
@@ -200,7 +200,7 @@
  * Pops the first element from the queue. What exactly is the first element,
  * is defined by the exact type of queue.
  */
-void *Queue::Pop()
+void *BinaryHeap::Pop()
 {
 	void *result;
 
@@ -222,7 +222,7 @@
  * Initializes a binary heap and allocates internal memory for maximum of
  * max_size elements
  */
-void Queue::Init(uint max_size)
+void BinaryHeap::Init(uint max_size)
 {
 	this->max_size = max_size;
 	this->size = 0;
--- a/src/pathfinder/npf/queue.h
+++ b/src/pathfinder/npf/queue.h
@@ -7,7 +7,7 @@
  * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
  */
 
-/** @file queue.h Simple Queue/Hash implementations. */
+/** @file queue.h Binary heap implementation, hash implementation. */
 
 #ifndef QUEUE_H
 #define QUEUE_H
@@ -24,12 +24,11 @@
 };
 
 
-/*
- *  Binary Heap
- *  For information, see:
- *   http://www.policyalmanac.org/games/binaryHeaps.htm
+/**
+ * Binary Heap.
+ * For information, see: http://www.policyalmanac.org/games/binaryHeaps.htm
  */
-struct Queue {
+struct BinaryHeap {
 	static const int BINARY_HEAP_BLOCKSIZE;
 	static const int BINARY_HEAP_BLOCKSIZE_BITS;
 	static const int BINARY_HEAP_BLOCKSIZE_MASK;