A pure Swift implementation of a generic priority queue data structure using a binary heap.
SwiftPriorityQueue is a pure Swift implementation of a generic priority queue data structure. It provides an efficient way to manage collections where elements are processed based on priority, using a binary heap for O(log n) performance on insertions and removals. It solves the need for a platform-agnostic, dependency-free priority queue in Swift projects.
Swift developers across macOS, iOS, Linux, and other platforms who need an efficient, generic priority queue for algorithms like A* pathfinding, task scheduling, or any scenario requiring prioritized processing.
Developers choose SwiftPriorityQueue for its simplicity, pure Swift implementation without Cocoa dependencies, excellent performance with binary heap operations, and full support for Swift's standard protocols like Sequence and Collection for easy integration.
A Generic Priority Queue in Pure Swift
Implemented purely in Swift without Cocoa dependencies, it works seamlessly on macOS, iOS, Linux, and all Swift-supported platforms, as highlighted in the README's platform badges.
Uses a classic binary heap to ensure O(log n) time complexity for push and pop operations, making it reliable for performance-critical algorithms like A* pathfinding.
Conforms to Sequence, IteratorProtocol, and Collection protocols, allowing easy iteration with for-in loops and integration with Swift's built-in functions.
Provides familiar methods like push(), pop(), and peek(), with flexible initialization options for ascending/descending order and starting arrays, as documented in the README.
The README explicitly states it is not thread-safe, requiring external synchronization if used in concurrent environments, which limits its use in multi-threaded applications.
The push with maxCount method is O(n) due to binary heap limitations, making it unsuitable for real-time applications needing efficient size-limited queues.
Only supports elements that implement Comparable, preventing the use of separate priority values without wrapping types, which can be restrictive for complex prioritization logic.
A functional tool-belt for Swift Language similar to Lo-Dash or Underscore.js in Javascript
💻 A fast and flexible O(n) difference algorithm framework for Swift collection.
Swift type modelling the success/failure of arbitrary operations.
EKAlgorithms contains some well known CS algorithms & data structures.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.