Fibonacci heap: Difference between revisions
m
→{{header|Wren}}: Minor tidy
m (→{{header|Phix}}: added syntax colouring, made p2js compatible) |
m (→{{header|Wren}}: Minor tidy) |
||
(One intermediate revision by one other user not shown) | |||
Line 16:
=={{header|C++}}==
<
template <class V> struct node {
Line 322:
}
</syntaxhighlight>
=={{header|Go}}==
A package. Implementation follows Fredman and Tarjan's 1987 paper.
<
import "fmt"
Line 575:
}
f(h.Node, "")
}</
A demonstration:
<
import (
Line 628:
h.Delete(x)
h.Vis()
}</
{{out}}
<pre>
Line 666:
=={{header|Julia}}==
{{trans|Python}}
<
export FNode, FibonacciHeap, insert, extractmin, findmin, decreasekey, delete!
Line 975:
print(h3)
println("The minimum of h3 is now: ", Minimum(h3).value
</
<pre>
Made heap 1:
Line 1,015:
=={{header|Kotlin}}==
{{trans|Go}}
<
class Node<V : Comparable<V>>(var value: V) {
Line 1,283:
h.delete(x)
h.visualize()
}</
{{out}}
Line 1,321:
=={{header|Nim}}==
{{trans|Go & Kotlin}}
<
type
Line 1,587:
echo "(deleting $#)" % node.value
heap.delete(node)
heap.visualize()</
{{out}}
Line 1,623:
=={{header|Phix}}==
{{trans|Go}}
<!--<
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span>
<span style="color: #008080;">enum</span> <span style="color: #000000;">VALUE</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">PARENT</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">CHILD</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">PREV</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">NEXT</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">RANK</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">MARK</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">NODELEN</span><span style="color: #0000FF;">=$</span>
Line 1,939:
<span style="color: #000000;">h</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">Delete</span><span style="color: #0000FF;">(</span><span style="color: #000000;">h</span><span style="color: #0000FF;">,</span><span style="color: #000000;">x</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">Vis</span><span style="color: #0000FF;">(</span><span style="color: #000000;">h</span><span style="color: #0000FF;">)</span>
<!--</
{{out}}
<pre>
Line 1,975:
=={{header|Python}}==
<
# internal node class
Line 2,157:
node.right.parent = parent
node.left.right = node.right
node.right.left = node.left</
=={{header|Raku}}==
{{trans|Go & Kotlin}}
<syntaxhighlight lang="raku"
subset vEle of Any;
Line 2,400:
say "deleting: ", $x.value;
$h.Delete($x);
$h.Vis;</
{{out}}
<pre>MakeHeap:
Line 2,437:
{{libheader|Wren-str}}
This just deals with nodes whose values are strings.
<
class Node {
Line 2,720:
System.print("(deleting '%(x.value)')")
h.delete(x)
h.visualize()</
{{out}}
|