Priority queue: Difference between revisions

m
Line 4,389:
heap(<)::top(H4, K4, V4). % K4=2, V4='Tax return'</syntaxhighlight>
 
Since `heap` is a parametrisedparametrized classobject in Logtalk, with the parameter being the ordering predicate, we actually use `heap(<)` object to get min ordering. There are two classesobjects provided in Logtalk that eliminate the unnecessary replication of the two most common orderings:
 
<syntaxhighlight lang="logtalk">:- object(minheap,
Line 4,416:
:- end_object.</syntaxhighlight>
 
Given the presence of these two classesobjects, all of the example code above could have `heap(<)` replaced with `minheap` for identical results (including identical performance). It also illustrates how quickly and easily other orderings could be provided at need.
 
=={{header|Lua}}==
17

edits