@@ -124,12 +124,12 @@ final class HeapTests: CollectionTestCase {
124124
125125 heap. insert ( contentsOf: ( 21 ... 50 ) . shuffled ( ) )
126126 expectEqual ( heap. count, 38 )
127- expectEqual ( heap. max ( ) , 50 )
128- expectEqual ( heap. min ( ) , 2 )
127+ expectEqual ( heap. max, 50 )
128+ expectEqual ( heap. min, 2 )
129129
130130 heap. insert ( contentsOf: [ - 10 , - 9 , - 8 , - 7 , - 6 , - 5 ] . shuffled ( ) )
131131 expectEqual ( heap. count, 44 )
132- expectEqual ( heap. min ( ) , - 10 )
132+ expectEqual ( heap. min, - 10 )
133133 }
134134
135135 func test_insert_contentsOf_withSequenceFunction( ) {
@@ -165,36 +165,36 @@ final class HeapTests: CollectionTestCase {
165165
166166 func test_min( ) {
167167 var heap = Heap < Int > ( )
168- expectNil ( heap. min ( ) )
168+ expectNil ( heap. min)
169169
170170 heap. insert ( 5 )
171- expectEqual ( 5 , heap. min ( ) )
171+ expectEqual ( 5 , heap. min)
172172
173173 heap. insert ( 12 )
174- expectEqual ( 5 , heap. min ( ) )
174+ expectEqual ( 5 , heap. min)
175175
176176 heap. insert ( 2 )
177- expectEqual ( 2 , heap. min ( ) )
177+ expectEqual ( 2 , heap. min)
178178
179179 heap. insert ( 1 )
180- expectEqual ( 1 , heap. min ( ) )
180+ expectEqual ( 1 , heap. min)
181181 }
182182
183183 func test_max( ) {
184184 var heap = Heap < Int > ( )
185- expectNil ( heap. max ( ) )
185+ expectNil ( heap. max)
186186
187187 heap. insert ( 42 )
188- expectEqual ( 42 , heap. max ( ) )
188+ expectEqual ( 42 , heap. max)
189189
190190 heap. insert ( 20 )
191- expectEqual ( 42 , heap. max ( ) )
191+ expectEqual ( 42 , heap. max)
192192
193193 heap. insert ( 63 )
194- expectEqual ( 63 , heap. max ( ) )
194+ expectEqual ( 63 , heap. max)
195195
196196 heap. insert ( 90 )
197- expectEqual ( 90 , heap. max ( ) )
197+ expectEqual ( 90 , heap. max)
198198 }
199199
200200 func test_popMin( ) {
@@ -345,133 +345,133 @@ final class HeapTests: CollectionTestCase {
345345 var heap = Heap ( stride ( from: 0 , through: 27 , by: 3 ) . shuffled ( ) )
346346 expectEqual (
347347 heap. itemsInAscendingOrder ( ) , [ 0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 27 ] )
348- expectEqual ( heap. min ( ) , 0 )
348+ expectEqual ( heap. min, 0 )
349349
350350 // No change
351351 heap. replaceMin ( with: 0 )
352352 expectEqual (
353353 heap. itemsInAscendingOrder ( ) , [ 0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 27 ] )
354- expectEqual ( heap. min ( ) , 0 )
354+ expectEqual ( heap. min, 0 )
355355
356356 // Even smaller
357357 heap. replaceMin ( with: - 1 )
358358 expectEqual (
359359 heap. itemsInAscendingOrder ( ) , [ - 1 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 27 ] )
360- expectEqual ( heap. min ( ) , - 1 )
360+ expectEqual ( heap. min, - 1 )
361361
362362 // Larger, but not enough to usurp
363363 heap. replaceMin ( with: 2 )
364364 expectEqual (
365365 heap. itemsInAscendingOrder ( ) , [ 2 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 27 ] )
366- expectEqual ( heap. min ( ) , 2 )
366+ expectEqual ( heap. min, 2 )
367367
368368 // Larger, moving another element to be the smallest
369369 heap. replaceMin ( with: 5 )
370370 expectEqual (
371371 heap. itemsInAscendingOrder ( ) , [ 3 , 5 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 27 ] )
372- expectEqual ( heap. min ( ) , 3 )
372+ expectEqual ( heap. min, 3 )
373373 }
374374
375375 func test_maximumReplacement( ) {
376376 var heap = Heap ( stride ( from: 0 , through: 27 , by: 3 ) . shuffled ( ) )
377377 expectEqual (
378378 heap. itemsInAscendingOrder ( ) , [ 0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 27 ] )
379- expectEqual ( heap. max ( ) , 27 )
379+ expectEqual ( heap. max, 27 )
380380
381381 // No change
382382 heap. replaceMax ( with: 27 )
383383 expectEqual (
384384 heap. itemsInAscendingOrder ( ) , [ 0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 27 ] )
385- expectEqual ( heap. max ( ) , 27 )
385+ expectEqual ( heap. max, 27 )
386386
387387 // Even larger
388388 heap. replaceMax ( with: 28 )
389389 expectEqual (
390390 heap. itemsInAscendingOrder ( ) , [ 0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 28 ] )
391- expectEqual ( heap. max ( ) , 28 )
391+ expectEqual ( heap. max, 28 )
392392
393393 // Smaller, but not enough to usurp
394394 heap. replaceMax ( with: 26 )
395395 expectEqual (
396396 heap. itemsInAscendingOrder ( ) , [ 0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 24 , 26 ] )
397- expectEqual ( heap. max ( ) , 26 )
397+ expectEqual ( heap. max, 26 )
398398
399399 // Smaller, moving another element to be the largest
400400 heap. replaceMax ( with: 23 )
401401 expectEqual (
402402 heap. itemsInAscendingOrder ( ) , [ 0 , 3 , 6 , 9 , 12 , 15 , 18 , 21 , 23 , 24 ] )
403- expectEqual ( heap. max ( ) , 24 )
403+ expectEqual ( heap. max, 24 )
404404
405405 // Check the finer details. As these peek into the stored structure, they
406406 // may need to be updated whenever the internal format changes.
407407 var heap2 = Heap ( raw: [ 1 ] )
408- expectEqual ( heap2. max ( ) , 1 )
408+ expectEqual ( heap2. max, 1 )
409409 expectEqual ( Array ( heap2. unordered) , [ 1 ] )
410410 expectEqual ( heap2. replaceMax ( with: 2 ) , 1 )
411- expectEqual ( heap2. max ( ) , 2 )
411+ expectEqual ( heap2. max, 2 )
412412 expectEqual ( Array ( heap2. unordered) , [ 2 ] )
413413
414414 heap2 = Heap ( raw: [ 1 , 2 ] )
415- expectEqual ( heap2. max ( ) , 2 )
415+ expectEqual ( heap2. max, 2 )
416416 expectEqual ( Array ( heap2. unordered) , [ 1 , 2 ] )
417417 expectEqual ( heap2. replaceMax ( with: 3 ) , 2 )
418- expectEqual ( heap2. max ( ) , 3 )
418+ expectEqual ( heap2. max, 3 )
419419 expectEqual ( Array ( heap2. unordered) , [ 1 , 3 ] )
420420 expectEqual ( heap2. replaceMax ( with: 0 ) , 3 )
421- expectEqual ( heap2. max ( ) , 1 )
421+ expectEqual ( heap2. max, 1 )
422422 expectEqual ( Array ( heap2. unordered) , [ 0 , 1 ] )
423423
424424 heap2 = Heap ( raw: [ 5 , 20 , 31 , 16 , 8 , 7 , 18 ] )
425- expectEqual ( heap2. max ( ) , 31 )
425+ expectEqual ( heap2. max, 31 )
426426 expectEqual ( Array ( heap2. unordered) , [ 5 , 20 , 31 , 16 , 8 , 7 , 18 ] )
427427 expectEqual ( heap2. replaceMax ( with: 29 ) , 31 )
428428 expectEqual ( Array ( heap2. unordered) , [ 5 , 20 , 29 , 16 , 8 , 7 , 18 ] )
429- expectEqual ( heap2. max ( ) , 29 )
429+ expectEqual ( heap2. max, 29 )
430430 expectEqual ( heap2. replaceMax ( with: 19 ) , 29 )
431431 expectEqual ( Array ( heap2. unordered) , [ 5 , 20 , 19 , 16 , 8 , 7 , 18 ] )
432- expectEqual ( heap2. max ( ) , 20 )
432+ expectEqual ( heap2. max, 20 )
433433 expectEqual ( heap2. replaceMax ( with: 15 ) , 20 )
434434 expectEqual ( Array ( heap2. unordered) , [ 5 , 16 , 19 , 15 , 8 , 7 , 18 ] )
435- expectEqual ( heap2. max ( ) , 19 )
435+ expectEqual ( heap2. max, 19 )
436436 expectEqual ( heap2. replaceMax ( with: 4 ) , 19 )
437437 expectEqual ( Array ( heap2. unordered) , [ 4 , 16 , 18 , 15 , 8 , 7 , 5 ] )
438- expectEqual ( heap2. max ( ) , 18 )
438+ expectEqual ( heap2. max, 18 )
439439 }
440440
441441 // MARK: -
442442
443443 func test_min_struct( ) {
444444 var heap = Heap < Task > ( )
445- expectNil ( heap. min ( ) )
445+ expectNil ( heap. min)
446446
447447 let firstTask = Task ( name: " Do something " , priority: 10 )
448448 heap. insert ( firstTask)
449- expectEqual ( heap. min ( ) , firstTask)
449+ expectEqual ( heap. min, firstTask)
450450
451451 let higherPriorityTask = Task ( name: " Urgent " , priority: 100 )
452452 heap. insert ( higherPriorityTask)
453- expectEqual ( heap. min ( ) , firstTask)
453+ expectEqual ( heap. min, firstTask)
454454
455455 let lowerPriorityTask = Task ( name: " Get this done today " , priority: 1 )
456456 heap. insert ( lowerPriorityTask)
457- expectEqual ( heap. min ( ) , lowerPriorityTask)
457+ expectEqual ( heap. min, lowerPriorityTask)
458458 }
459459
460460 func test_max_struct( ) {
461461 var heap = Heap < Task > ( )
462- expectNil ( heap. max ( ) )
462+ expectNil ( heap. max)
463463
464464 let firstTask = Task ( name: " Do something " , priority: 10 )
465465 heap. insert ( firstTask)
466- expectEqual ( heap. max ( ) , firstTask)
466+ expectEqual ( heap. max, firstTask)
467467
468468 let lowerPriorityTask = Task ( name: " Get this done today " , priority: 1 )
469469 heap. insert ( lowerPriorityTask)
470- expectEqual ( heap. max ( ) , firstTask)
470+ expectEqual ( heap. max, firstTask)
471471
472472 let higherPriorityTask = Task ( name: " Urgent " , priority: 100 )
473473 heap. insert ( higherPriorityTask)
474- expectEqual ( heap. max ( ) , higherPriorityTask)
474+ expectEqual ( heap. max, higherPriorityTask)
475475 }
476476
477477 func test_popMin_struct( ) {
@@ -516,7 +516,7 @@ final class HeapTests: CollectionTestCase {
516516
517517 func test_initializer_fromCollection( ) {
518518 var heap = Heap ( ( 1 ... 20 ) . shuffled ( ) )
519- expectEqual ( heap. max ( ) , 20 )
519+ expectEqual ( heap. max, 20 )
520520
521521 expectEqual ( heap. popMin ( ) , 1 )
522522 expectEqual ( heap. popMax ( ) , 20 )
@@ -565,12 +565,12 @@ final class HeapTests: CollectionTestCase {
565565 let input = ( 0 ..< c) . shuffled ( using: & rng)
566566 let heap = Heap ( input)
567567 if c > 0 {
568- expectEqual ( heap. min ( ) , 0 )
569- expectEqual ( heap. max ( ) , c - 1 )
568+ expectEqual ( heap. min, 0 )
569+ expectEqual ( heap. max, c - 1 )
570570 expectEqualElements ( heap. itemsInAscendingOrder ( ) , 0 ..< c)
571571 } else {
572- expectNil ( heap. min ( ) )
573- expectNil ( heap. max ( ) )
572+ expectNil ( heap. min)
573+ expectNil ( heap. max)
574574 expectEqualElements ( heap. itemsInAscendingOrder ( ) , [ ] )
575575 }
576576 }
0 commit comments