Submitted on October 4, 2017 at 09:44 AM

New Paste 1 (JavaScript)

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041
var heap_test = function() {

var nodes = []

var elt

var h = new GZKM.Heap()

var test_no = 0

function push(priority, elt) {
	nodes.push(h.push(priority, elt))
	nodes.sort(function(a, b){return b.priority - a.priority})
	console.log(++test_no)
}

function pop() {
	var popped = h.pop()
	if(nodes.length == 0)
		console.assert(popped === undefined)
	else {
		var found = false
		for(var i = nodes.length-1; i >= 0 && nodes[i].priority == nodes[nodes.length-1].priority; i--)
			if(popped.priority == nodes[i].priority && popped.elt == nodes[i].elt) {
				found = true;
				nodes.splice(i, 1)
				break
			}
		console.assert(found)
	}
	console.log(++test_no)
}

function reprioritize(i, newPriority) {
	h.reprioritize(nodes[i], newPriority)
	console.assert(nodes[i].priority == newPriority)
	nodes.sort(function(a, b){return b.priority - a.priority})
	console.log(++test_no)
}

push(27, 1)
push(43, 2)
push(36, 3)
pop()
reprioritize(0, 21)
pop()
push(9, 7)
reprioritize(0, 26)
push(22, 9)
push(11, 10)
reprioritize(1, 17)
pop()
push(12, 13)
reprioritize(3, 17)
reprioritize(2, 2)
reprioritize(3, 19)
reprioritize(3, 6)
pop()
reprioritize(0, 23)
reprioritize(1, 34)
reprioritize(2, 24)
push(13, 22)
push(41, 23)
push(6, 24)
reprioritize(2, 12)
push(31, 26)
push(25, 27)
reprioritize(0, 27)
push(46, 29)
reprioritize(2, 13)
reprioritize(0, 45)
push(14, 32)
pop()
reprioritize(6, 14)
push(37, 35)
reprioritize(8, 26)
reprioritize(3, 34)
push(4, 38)
reprioritize(8, 32)
push(18, 40)
reprioritize(10, 12)
push(44, 42)
reprioritize(7, 45)
reprioritize(11, 28)
push(47, 45)
pop()
pop()
pop()
pop()
push(1, 50)
push(36, 51)
push(15, 52)
reprioritize(10, 44)
push(29, 54)
push(17, 55)
pop()
push(31, 57)
push(9, 58)
pop()
pop()
push(47, 61)
reprioritize(5, 36)
push(33, 63)
reprioritize(8, 24)
push(32, 65)
reprioritize(4, 3)
push(18, 67)
reprioritize(4, 15)
reprioritize(11, 46)
reprioritize(2, 45)
push(21, 71)
push(29, 72)
reprioritize(8, 14)
push(0, 74)
reprioritize(5, 0)
reprioritize(10, 24)
pop()
push(43, 78)
push(27, 79)
push(9, 80)
push(32, 81)
push(37, 82)
reprioritize(7, 25)
reprioritize(8, 21)
push(29, 85)
pop()
push(43, 87)
reprioritize(19, 28)
push(28, 89)
reprioritize(1, 26)
reprioritize(26, 13)
reprioritize(7, 6)
reprioritize(3, 18)
reprioritize(18, 19)
pop()
push(24, 96)
reprioritize(2, 20)
push(49, 98)
pop()
push(44, 100)
push(5, 101)
reprioritize(14, 4)
reprioritize(3, 32)
reprioritize(10, 47)
push(4, 105)
reprioritize(2, 11)
reprioritize(3, 49)
push(18, 108)
push(22, 109)
push(10, 110)
push(1, 111)
push(30, 112)
reprioritize(15, 5)
push(44, 114)
push(22, 115)
push(8, 116)
push(32, 117)
reprioritize(27, 24)
pop()
reprioritize(22, 0)
pop()
reprioritize(20, 29)
reprioritize(27, 21)
push(31, 124)
push(33, 125)
reprioritize(15, 10)
reprioritize(17, 31)
push(9, 128)
reprioritize(28, 13)
push(45, 130)
push(16, 131)
reprioritize(40, 40)
reprioritize(30, 26)
push(7, 134)
push(6, 135)
reprioritize(43, 18)
pop()
reprioritize(30, 22)
reprioritize(14, 36)
pop()
pop()
push(1, 142)
reprioritize(25, 22)
push(19, 144)
reprioritize(14, 21)
reprioritize(9, 11)
pop()
push(28, 148)
pop()
push(34, 150)
reprioritize(9, 20)
pop()
reprioritize(37, 46)
push(34, 154)
pop()
pop()
pop()
push(25, 158)
push(22, 159)
reprioritize(2, 40)
reprioritize(2, 13)
push(24, 162)
push(9, 163)
push(19, 164)
push(32, 165)
push(44, 166)
reprioritize(35, 29)
reprioritize(8, 26)
push(10, 169)
pop()
reprioritize(17, 34)
push(21, 172)
pop()
reprioritize(42, 13)
reprioritize(33, 26)
reprioritize(18, 2)
push(34, 177)
push(42, 178)
reprioritize(23, 28)
pop()
reprioritize(18, 8)
push(8, 182)
reprioritize(11, 48)
reprioritize(11, 33)
push(4, 185)
pop()
push(18, 187)
reprioritize(46, 0)
reprioritize(49, 47)
push(3, 190)
reprioritize(41, 13)
reprioritize(39, 42)
push(2, 193)
push(25, 194)
reprioritize(33, 7)
push(10, 196)
reprioritize(36, 21)
reprioritize(1, 28)
push(48, 199)
push(2, 200)
reprioritize(27, 47)
reprioritize(26, 39)
reprioritize(44, 3)
push(47, 204)
reprioritize(41, 9)
push(34, 206)
reprioritize(3, 42)
pop()
reprioritize(46, 29)
reprioritize(34, 35)
reprioritize(45, 35)
push(38, 212)
push(49, 213)
reprioritize(51, 17)
pop()
push(43, 216)
reprioritize(0, 29)
pop()
push(41, 219)
reprioritize(58, 26)
push(42, 221)
push(17, 222)
reprioritize(16, 11)
reprioritize(52, 40)
push(17, 225)
pop()
reprioritize(29, 40)
reprioritize(5, 7)
reprioritize(12, 5)
pop()
push(0, 231)
push(26, 232)
reprioritize(12, 16)
reprioritize(60, 29)
push(47, 235)
push(1, 236)
push(31, 237)
reprioritize(22, 7)
pop()
push(14, 240)
push(12, 241)
push(12, 242)
reprioritize(40, 10)
reprioritize(26, 24)
push(20, 245)
reprioritize(4, 37)
reprioritize(50, 16)
reprioritize(33, 6)
push(10, 249)
reprioritize(45, 37)
reprioritize(66, 17)
push(33, 252)
reprioritize(53, 8)
pop()
reprioritize(67, 33)
reprioritize(13, 7)
push(29, 257)
push(9, 258)
reprioritize(9, 38)
reprioritize(2, 24)
pop()
push(43, 262)
reprioritize(15, 20)
pop()
reprioritize(3, 19)
pop()
reprioritize(1, 23)
push(12, 268)
pop()
push(42, 270)
push(7, 271)
push(21, 272)
pop()
reprioritize(8, 41)
push(31, 275)
push(37, 276)
push(4, 277)
push(48, 278)
push(31, 279)
push(16, 280)
pop()
push(39, 282)
push(4, 283)
reprioritize(72, 30)
push(20, 285)
pop()
pop()
reprioritize(24, 27)
push(4, 289)
push(33, 290)
pop()
reprioritize(4, 7)
reprioritize(41, 11)
push(36, 294)
push(18, 295)
push(13, 296)
reprioritize(57, 44)
push(34, 298)
push(25, 299)
push(14, 300)
reprioritize(57, 18)
reprioritize(82, 5)
pop()
pop()
pop()
push(43, 306)
reprioritize(67, 26)
push(3, 308)
reprioritize(72, 24)
reprioritize(60, 29)
pop()
push(38, 312)
reprioritize(70, 10)
reprioritize(6, 17)
push(37, 315)
push(3, 316)
reprioritize(58, 23)
push(41, 318)
push(18, 319)
pop()
push(13, 321)
push(40, 322)
reprioritize(0, 30)
push(11, 324)
reprioritize(10, 35)
reprioritize(33, 4)
push(0, 327)
reprioritize(15, 3)
push(45, 329)
reprioritize(67, 49)
pop()
push(13, 332)
pop()
push(31, 334)
push(10, 335)
push(5, 336)
push(18, 337)
push(42, 338)
pop()
push(29, 340)
push(20, 341)
reprioritize(59, 22)
reprioritize(51, 40)
pop()
reprioritize(3, 30)
pop()
push(30, 347)
reprioritize(64, 14)
pop()
pop()
reprioritize(87, 32)
pop()
reprioritize(19, 4)
reprioritize(24, 36)
reprioritize(26, 9)
pop()
reprioritize(70, 41)
reprioritize(89, 24)
pop()
reprioritize(81, 35)
pop()
push(47, 362)
push(26, 363)
reprioritize(31, 18)
reprioritize(82, 3)
pop()
reprioritize(26, 28)
pop()
push(34, 369)
reprioritize(28, 34)
push(26, 371)
reprioritize(46, 15)
push(39, 373)
reprioritize(38, 6)
push(24, 375)
reprioritize(54, 39)
reprioritize(84, 9)
push(14, 378)
reprioritize(86, 39)
pop()
pop()
reprioritize(7, 37)
pop()
pop()
push(25, 385)
push(29, 386)
push(4, 387)
push(31, 388)
reprioritize(36, 7)
push(31, 390)
reprioritize(83, 20)
pop()
push(37, 393)
push(46, 394)
push(4, 395)
pop()
pop()
push(47, 398)
pop()
reprioritize(36, 31)
push(7, 401)
reprioritize(31, 45)
pop()
pop()
reprioritize(70, 26)
pop()
reprioritize(9, 37)
pop()
push(16, 409)
reprioritize(51, 10)
push(35, 411)
push(35, 412)
push(40, 413)
reprioritize(52, 14)
push(20, 415)
pop()
push(28, 417)
reprioritize(19, 25)
push(10, 419)
reprioritize(1, 43)
reprioritize(29, 32)
push(5, 422)
reprioritize(86, 25)
push(37, 424)
reprioritize(22, 8)
reprioritize(57, 0)
pop()
pop()
push(19, 429)
push(1, 430)
reprioritize(28, 10)
reprioritize(88, 48)
push(43, 433)
pop()
push(26, 435)
reprioritize(10, 2)
pop()
pop()
reprioritize(85, 7)
pop()
pop()
push(35, 442)
reprioritize(18, 48)
push(26, 444)
push(16, 445)
reprioritize(28, 4)
reprioritize(78, 43)
pop()
push(22, 449)
reprioritize(0, 45)
push(47, 451)
reprioritize(24, 12)
pop()
push(43, 454)
reprioritize(82, 39)
push(9, 456)
push(7, 457)
reprioritize(15, 11)
pop()
push(16, 460)
pop()
push(12, 462)
pop()
reprioritize(12, 17)
reprioritize(84, 15)
push(14, 466)
push(13, 467)
push(22, 468)
pop()
pop()
reprioritize(73, 28)
push(37, 472)
push(40, 473)
push(20, 474)
pop()
push(11, 476)
reprioritize(37, 17)
reprioritize(50, 1)
push(6, 479)
reprioritize(60, 17)
reprioritize(66, 32)
reprioritize(24, 25)
push(12, 483)
reprioritize(64, 19)
push(6, 485)
reprioritize(97, 10)
reprioritize(41, 15)
push(36, 488)
reprioritize(59, 39)
push(2, 490)
push(43, 491)
push(39, 492)
reprioritize(109, 31)
reprioritize(39, 35)
push(27, 495)
reprioritize(32, 33)
reprioritize(47, 5)
reprioritize(8, 18)
push(33, 499)
reprioritize(66, 36)
reprioritize(75, 27)
push(31, 502)
pop()
push(23, 504)
push(0, 505)
reprioritize(28, 25)
pop()
reprioritize(87, 9)
reprioritize(65, 44)
reprioritize(60, 1)
reprioritize(61, 19)
reprioritize(8, 4)
pop()
push(16, 514)
pop()
pop()
pop()
pop()
reprioritize(68, 2)
pop()
pop()
reprioritize(8, 7)
pop()
reprioritize(33, 27)
pop()
reprioritize(46, 7)
push(33, 527)
pop()
pop()
reprioritize(51, 41)
pop()
reprioritize(33, 30)
push(48, 533)
push(30, 534)
reprioritize(58, 9)
push(12, 536)
reprioritize(30, 19)
pop()
pop()
push(30, 540)
pop()
reprioritize(69, 39)
reprioritize(79, 23)
pop()
reprioritize(72, 31)
push(5, 546)
push(13, 547)
pop()
reprioritize(74, 20)
pop()
reprioritize(62, 21)
reprioritize(15, 45)
reprioritize(18, 38)
pop()
reprioritize(44, 32)
push(23, 556)
push(33, 557)
reprioritize(9, 37)
reprioritize(75, 49)
pop()
reprioritize(82, 14)
push(36, 562)
push(49, 563)
push(36, 564)
pop()
pop()
reprioritize(62, 33)
pop()
pop()
reprioritize(24, 43)
pop()
reprioritize(28, 44)
reprioritize(55, 9)
reprioritize(72, 3)
reprioritize(60, 5)
reprioritize(54, 49)
reprioritize(59, 15)
pop()
reprioritize(90, 19)
pop()
pop()
pop()
pop()
reprioritize(62, 10)
push(4, 585)
pop()
pop()
reprioritize(66, 3)
pop()
pop()
pop()
push(43, 592)
reprioritize(24, 11)
reprioritize(60, 47)
push(32, 595)
pop()
reprioritize(61, 1)
pop()
reprioritize(48, 26)
reprioritize(1, 36)
pop()
pop()
pop()
reprioritize(68, 21)
push(16, 605)
reprioritize(71, 4)
pop()
reprioritize(77, 34)
pop()
pop()
pop()
reprioritize(22, 15)
reprioritize(3, 19)
push(22, 614)
pop()
push(19, 616)
reprioritize(86, 1)
pop()
pop()
push(25, 620)
reprioritize(48, 22)
reprioritize(15, 27)
reprioritize(87, 12)
pop()
reprioritize(85, 33)
pop()
reprioritize(68, 20)
reprioritize(23, 15)
pop()
reprioritize(73, 37)
reprioritize(45, 40)
pop()
reprioritize(8, 31)
pop()
reprioritize(26, 21)
reprioritize(57, 38)
push(40, 637)
pop()
pop()
pop()
reprioritize(11, 8)
pop()
pop()
push(22, 644)
pop()
reprioritize(43, 11)
reprioritize(65, 11)
pop()
pop()
reprioritize(70, 24)
pop()
push(17, 652)
reprioritize(39, 13)
reprioritize(16, 10)
pop()
pop()
pop()
reprioritize(28, 40)
push(45, 659)
reprioritize(21, 7)
pop()
push(26, 662)
push(34, 663)
pop()
reprioritize(4, 0)
reprioritize(32, 46)
reprioritize(67, 13)
reprioritize(62, 23)
reprioritize(11, 23)
reprioritize(18, 1)
reprioritize(9, 4)
pop()
pop()
push(29, 674)
pop()
pop()
pop()
reprioritize(41, 31)
reprioritize(13, 31)
reprioritize(30, 27)
reprioritize(37, 43)
reprioritize(27, 18)
reprioritize(70, 43)
reprioritize(64, 44)
push(48, 685)
pop()
reprioritize(15, 2)
reprioritize(50, 45)
push(29, 689)
pop()
pop()
reprioritize(40, 25)
reprioritize(1, 3)
pop()
reprioritize(32, 47)
pop()
pop()
pop()
reprioritize(36, 27)
reprioritize(1, 47)
reprioritize(16, 35)
pop()
reprioritize(4, 49)
pop()
pop()
reprioritize(61, 3)
reprioritize(13, 28)
reprioritize(35, 33)
push(31, 709)
reprioritize(47, 35)
push(47, 711)
reprioritize(29, 29)
reprioritize(18, 29)
pop()
reprioritize(30, 35)
push(36, 716)
push(26, 717)
pop()
pop()
reprioritize(57, 19)
reprioritize(20, 16)
push(33, 722)
reprioritize(51, 26)
reprioritize(22, 26)
pop()
pop()
reprioritize(60, 13)
reprioritize(8, 47)
push(32, 729)
reprioritize(20, 40)
pop()
reprioritize(18, 15)
reprioritize(26, 34)
reprioritize(38, 3)
reprioritize(50, 36)
pop()
reprioritize(12, 7)
reprioritize(43, 19)
push(34, 739)
pop()
reprioritize(60, 32)
pop()
pop()
pop()
reprioritize(27, 37)
pop()
pop()
pop()
push(38, 749)
reprioritize(55, 20)
reprioritize(46, 24)
push(8, 752)
pop()
pop()
push(46, 755)
reprioritize(43, 16)
push(15, 757)
pop()
reprioritize(20, 32)
push(43, 760)
reprioritize(1, 39)
reprioritize(37, 43)
reprioritize(2, 32)
push(23, 764)
reprioritize(11, 1)
reprioritize(45, 11)
reprioritize(53, 31)
reprioritize(37, 49)
push(14, 769)
reprioritize(1, 19)
pop()
pop()
pop()
push(11, 774)
reprioritize(20, 37)
pop()
reprioritize(5, 39)
push(14, 778)
pop()
pop()
reprioritize(50, 46)
reprioritize(49, 14)
pop()
push(17, 784)
reprioritize(35, 35)
push(7, 786)
pop()
reprioritize(7, 29)
push(42, 789)
pop()
reprioritize(37, 49)
pop()
push(18, 793)
reprioritize(51, 5)
pop()
push(36, 796)
reprioritize(19, 10)
push(7, 798)
reprioritize(31, 37)
push(21, 800)
pop()
pop()
push(27, 803)
reprioritize(51, 28)
push(27, 805)
reprioritize(34, 20)
pop()
push(33, 808)
pop()
pop()
reprioritize(37, 32)
pop()
push(3, 813)
reprioritize(14, 8)
reprioritize(22, 45)
push(18, 816)
pop()
reprioritize(5, 23)
pop()
reprioritize(9, 23)
pop()
reprioritize(6, 29)
reprioritize(0, 42)
pop()
reprioritize(35, 5)
reprioritize(24, 16)
reprioritize(22, 31)
reprioritize(18, 1)
pop()
reprioritize(36, 8)
pop()
reprioritize(29, 5)
push(30, 833)
pop()
reprioritize(8, 3)
push(0, 836)
pop()
pop()
pop()
reprioritize(9, 7)
reprioritize(44, 25)
pop()
reprioritize(30, 36)
push(26, 844)
reprioritize(37, 23)
push(48, 846)
pop()
push(9, 848)
reprioritize(34, 0)
pop()
reprioritize(8, 33)
pop()
pop()
push(18, 854)
pop()
reprioritize(37, 28)
pop()
reprioritize(19, 8)
push(1, 859)
push(39, 860)
pop()
push(26, 862)
pop()
reprioritize(9, 49)
push(12, 865)
pop()
pop()
reprioritize(38, 11)
pop()
reprioritize(21, 47)
reprioritize(25, 28)
reprioritize(25, 20)
pop()
push(42, 874)
reprioritize(23, 33)
reprioritize(8, 0)
pop()
push(38, 878)
push(40, 879)
push(34, 880)
pop()
push(33, 882)
pop()
reprioritize(34, 42)
pop()
reprioritize(40, 20)
reprioritize(28, 38)
pop()
push(22, 889)
reprioritize(20, 35)
reprioritize(40, 30)
reprioritize(9, 2)
reprioritize(13, 22)
push(7, 894)
push(2, 895)
pop()
reprioritize(30, 46)
push(40, 898)
reprioritize(16, 1)
pop()
reprioritize(18, 4)
pop()
reprioritize(29, 32)
reprioritize(33, 26)
pop()
push(39, 906)
reprioritize(10, 5)
pop()
pop()
reprioritize(20, 19)
push(17, 911)
reprioritize(19, 3)
reprioritize(10, 4)
pop()
push(42, 915)
pop()
reprioritize(15, 14)
pop()
pop()
pop()
reprioritize(1, 10)
push(2, 922)
push(47, 923)
pop()
reprioritize(29, 31)
reprioritize(6, 17)
push(1, 927)
pop()
reprioritize(7, 28)
pop()
pop()
pop()
reprioritize(1, 11)
reprioritize(26, 36)
pop()
reprioritize(28, 47)
push(39, 937)
push(17, 938)
pop()
pop()
reprioritize(11, 17)
pop()
pop()
push(43, 944)
pop()
pop()
reprioritize(32, 17)
pop()
reprioritize(33, 40)
push(24, 950)
push(31, 951)
pop()
reprioritize(16, 30)
push(42, 954)
push(47, 955)
pop()
pop()
reprioritize(25, 19)
reprioritize(6, 35)
pop()
push(20, 961)
pop()
push(38, 963)
pop()
pop()
reprioritize(21, 1)
reprioritize(31, 28)
pop()
pop()
push(32, 970)
reprioritize(13, 2)
reprioritize(6, 49)
pop()
push(10, 974)
pop()
reprioritize(13, 47)
pop()
reprioritize(29, 49)
reprioritize(3, 39)
pop()
reprioritize(21, 16)
reprioritize(7, 44)
pop()
pop()
reprioritize(18, 21)
reprioritize(2, 0)
reprioritize(4, 40)
push(0, 988)
pop()
pop()
push(12, 991)
reprioritize(11, 28)
reprioritize(0, 8)
reprioritize(10, 34)
pop()
pop()
push(7, 997)
pop()
pop()

}