Skip to content

Commit 53831b3

Browse files
committed
[Heap] Update docs
1 parent e10396b commit 53831b3

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

Documentation/Heap.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ This works by adding the new element into the end of the backing array and then
5353
You can also insert a sequence of elements into a `Heap`:
5454

5555
```swift
56-
var heap = Heap((0..<10))
57-
heap.insert(contentsOf: (20...100).shuffled())
56+
var heap = Heap(0 ..< 10)
57+
heap.insert(contentsOf: (20 ... 100).shuffled())
5858
heap.insert(contentsOf: [-5, -6, -8, -12, -3])
5959
```
6060

@@ -63,9 +63,9 @@ heap.insert(contentsOf: [-5, -6, -8, -12, -3])
6363
As mentioned earlier, the smallest and largest elements can be queried in constant time:
6464

6565
```swift
66-
var heap = Heap((1...20))
67-
let min = heap.min() // min = 1
68-
let max = heap.max() // max = 20
66+
var heap = Heap(1 ... 20)
67+
let min = heap.min // 1
68+
let max = heap.max // 20
6969
```
7070

7171
In a min-max heap, the smallest element is stored at index 0 in the backing array; the largest element is stored at either index 1 or index 2, the first max level in the heap (so to look up the largest, we compare the two and return the larger one).

Sources/HeapModule/Heap.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
///
1818
/// var queue: Heap<Int> = [3, 4, 1, 2]
1919
/// queue.insert(0)
20-
/// print(queue.min()) // 0
20+
/// print(queue.min) // 0
2121
/// print(queue.popMax()) // 4
22-
/// print(queue.max()) // 3
22+
/// print(queue.max) // 3
2323
///
2424
/// `Heap` implements the min-max heap data structure, based on
2525
/// [Atkinson et al. 1986].

0 commit comments

Comments
 (0)