diff options
Diffstat (limited to 'bin/ai/library/queue/binary_heap')
-rw-r--r-- | bin/ai/library/queue/binary_heap/library.nut | 6 | ||||
-rw-r--r-- | bin/ai/library/queue/binary_heap/main.nut | 14 |
2 files changed, 10 insertions, 10 deletions
diff --git a/bin/ai/library/queue/binary_heap/library.nut b/bin/ai/library/queue/binary_heap/library.nut index b0caf7d09..5216fb588 100644 --- a/bin/ai/library/queue/binary_heap/library.nut +++ b/bin/ai/library/queue/binary_heap/library.nut @@ -1,14 +1,14 @@ /* $Id$ */ -class BinaryHeap extends AILibrary { +class Binary_Heap extends AILibrary { function GetAuthor() { return "OpenTTD NoAI Developers Team"; } function GetName() { return "Binary Heap"; } function GetShortName() { return "QUBH"; } function GetDescription() { return "An implementation of a Binary Heap"; } function GetVersion() { return 1; } function GetDate() { return "2008-06-10"; } - function CreateInstance() { return "BinaryHeap"; } + function CreateInstance() { return "Binary_Heap"; } function GetCategory() { return "Queue"; } } -RegisterLibrary(BinaryHeap()); +RegisterLibrary(Binary_Heap()); diff --git a/bin/ai/library/queue/binary_heap/main.nut b/bin/ai/library/queue/binary_heap/main.nut index 1bbb3914f..05fd452f3 100644 --- a/bin/ai/library/queue/binary_heap/main.nut +++ b/bin/ai/library/queue/binary_heap/main.nut @@ -5,7 +5,7 @@ * Peek and Pop always return the current lowest value in the list. * Sort is done on insertion and on deletion. */ -class BinaryHeap +class Binary_Heap { _queue = null; _count = 0; @@ -55,7 +55,7 @@ class BinaryHeap function Exists(item); }; -function BinaryHeap::Insert(item, priority) +function Binary_Heap::Insert(item, priority) { /* Append dummy entry */ _queue.append(0); @@ -71,7 +71,7 @@ function BinaryHeap::Insert(item, priority) return true; } -function BinaryHeap::Pop() +function Binary_Heap::Pop() { if (_count == 0) return null; @@ -86,19 +86,19 @@ function BinaryHeap::Pop() return node[0]; } -function BinaryHeap::Peek() +function Binary_Heap::Peek() { if (_count == 0) return null; return _queue[0][0]; } -function BinaryHeap::Count() +function Binary_Heap::Count() { return _count; } -function BinaryHeap::Exists(item) +function Binary_Heap::Exists(item) { /* Brute-force find the item (there is no faster way, as we don't have the priority number) */ foreach (node in _queue) { @@ -110,7 +110,7 @@ function BinaryHeap::Exists(item) -function BinaryHeap::_BubbleDown() +function Binary_Heap::_BubbleDown() { if (_count == 0) return; |