kodeco.com Forums

Swift Algorithm Club – Heap and Priority Queue Data Structure

In this Swift Algorithm Club tutorial, you’ll learn how to implement a heap in Swift 3, a way to implement a priority queue.

This is a companion discussion topic for the original entry at https://www.raywenderlich.com/586-swift-algorithm-club-heap-and-priority-queue-data-structure

Xcode 9 / Swift 4 doesn’t seem to like your swap implementation:

“Simultaneous accesses to parameter ‘self’, but modification requires exclusive access; consider copying to a local variable”

You can use:

    elements.swapAt(firstIndex, secondIndex)

This tutorial is more than six months old so questions are no longer supported at the moment for it. We will update it as soon as possible. Thank you! :]