1
1
/// The `Heap` protocol
2
- protocol Heap {
2
+ public protocol Heap {
3
3
/// The type to store in the `Heap`
4
4
associatedtype T
5
5
/// The storage array of the `Heap`
@@ -144,9 +144,9 @@ public struct MaxHeap<T: Comparable>: Heap {
144
144
/// Public init
145
145
public init ( ) { }
146
146
/// The storage array of the `Heap`
147
- internal var storage : [ T ] = [ ]
147
+ public var storage : [ T ] = [ ]
148
148
/// The `MaxHeap` iterative `heapifyUp` algorithm.
149
- mutating internal func heapifyUp( ) {
149
+ mutating public func heapifyUp( ) {
150
150
var index = self . size - 1
151
151
while ( hasParent ( index) && self . storage [ index] > getParent ( index) ) {
152
152
let parentIndex = Self . getParentIndex ( index)
@@ -155,7 +155,7 @@ public struct MaxHeap<T: Comparable>: Heap {
155
155
}
156
156
}
157
157
/// The `MaxHeap` iterative `heapifyDown` algorithm.
158
- mutating internal func heapifyDown( ) {
158
+ mutating public func heapifyDown( ) {
159
159
var index = 0
160
160
while ( hasLeftChild ( index) ) {
161
161
var largest = Self . getLeftChildIndex ( index)
@@ -178,9 +178,9 @@ public struct MinHeap<T: Comparable>: Heap {
178
178
/// Public init
179
179
public init ( ) { }
180
180
/// The storage array of the `Heap`
181
- internal var storage : [ T ] = [ ]
181
+ public var storage : [ T ] = [ ]
182
182
/// The `MinHeap` iterative `heapifyUp` algorithm.
183
- mutating internal func heapifyUp( ) {
183
+ mutating public func heapifyUp( ) {
184
184
var index = self . size - 1
185
185
while ( hasParent ( index) && self . storage [ index] < getParent ( index) ) {
186
186
let parentIndex = Self . getParentIndex ( index)
@@ -189,7 +189,7 @@ public struct MinHeap<T: Comparable>: Heap {
189
189
}
190
190
}
191
191
/// The `MinHeap` iterative `heapifyDown` algorithm.
192
- mutating internal func heapifyDown( ) {
192
+ mutating public func heapifyDown( ) {
193
193
var index = 0
194
194
while ( hasLeftChild ( index) ) {
195
195
var smallest = Self . getLeftChildIndex ( index)
@@ -212,9 +212,9 @@ public struct MaxHeapRecursive<T: Comparable>: Heap {
212
212
/// Public init
213
213
public init ( ) { }
214
214
/// The storage array of the `Heap`
215
- internal var storage : [ T ] = [ ]
215
+ public var storage : [ T ] = [ ]
216
216
/// The `MaxHeapRecursive` recursive `heapifyUp` starter method.
217
- mutating internal func heapifyUp( ) {
217
+ mutating public func heapifyUp( ) {
218
218
heapifyUp ( at: self . size - 1 )
219
219
}
220
220
/// The `MaxHeapRecursive` recursive `heapifyUp` algorithm.
@@ -228,7 +228,7 @@ public struct MaxHeapRecursive<T: Comparable>: Heap {
228
228
}
229
229
}
230
230
/// The `MaxHeapRecursive` recursive `heapifyDown` starter method.
231
- mutating internal func heapifyDown( ) {
231
+ mutating public func heapifyDown( ) {
232
232
heapifyDown ( at: 0 )
233
233
}
234
234
/// The `MaxHeapRecursive` recursive `heapifyDown` algorithm.
@@ -257,9 +257,9 @@ public struct MinHeapRecursive<T: Comparable>: Heap {
257
257
/// Public init
258
258
public init ( ) { }
259
259
/// The storage array of the `Heap`
260
- internal var storage : [ T ] = [ ]
260
+ public var storage : [ T ] = [ ]
261
261
/// The `MinHeapRecursive` recursive `heapifyUp` starter method.
262
- mutating internal func heapifyUp( ) {
262
+ mutating public func heapifyUp( ) {
263
263
heapifyUp ( at: self . size - 1 )
264
264
}
265
265
/// The `MinHeapRecursive` recursive `heapifyUp` algorithm.
@@ -273,7 +273,7 @@ public struct MinHeapRecursive<T: Comparable>: Heap {
273
273
}
274
274
}
275
275
/// The `MinHeapRecursive` recursive `heapifyDown` starter method.
276
- mutating internal func heapifyDown( ) {
276
+ mutating public func heapifyDown( ) {
277
277
self . heapifyDown ( at: 0 )
278
278
}
279
279
/// The `MinHeapRecursive` recursive `heapifyDown` algorithm.
0 commit comments