## ## Datastructures: GAP package providing common datastructures. ## ## Copyright (C) 2015-2017 The datastructures team. ## For list of the team members, please refer to the COPYRIGHT file. ## ## This package is licensed under the GPL 2 or later, please refer ## to the COPYRIGHT.md and LICENSE files for details. ## # see # Fredman, Sedgewick, Sleator, Tarjan (1986), # "The pairing heap: a new form of self-adjusting heap" # http://www.cs.cmu.edu/afs/cs.cmu.edu/user/sleator/www/papers/pairing-heaps.pdf #
InstallGlobalFunction(PairingHeap, function(arg...)
local isLess, data, heap, x;
isLess := \<;
data := [];
if Length(arg) = 1then if IsFunction(arg[1]) then
isLess := arg[1]; else
data := arg[1]; fi; elif Length(arg) = 2then
isLess := arg[1];
data := arg[2]; elif Length(arg) > 2then
Error("Wrong number of arguments"); fi;
# ![1] node count # ![2] comparison function # ![3] nodes # # a node is a list of length 3 # node[1] data # node[2] number of nodes in the subheap # node[3] list of subheaps
heap := Objectify(PairingHeapTypeMutable, [0, isLess, []]);
for x in data do
PairingHeapPush(heap, x);
od;
return heap; end);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.