Swift Collections is a package of data structure implementations for the Swift programming language.
The package addresses the need for specialized collection types beyond Swift's standard library offerings. It provides ownership-aware variants like UniqueArray and RigidArray with different memory management strategies, double-ended queue implementations using ring buffers in both copyable and noncopyable forms, and ordered variants of Set and Dictionary that preserve insertion order. The package also includes efficient bit-level collections for representing sets of integers and boolean arrays, a min-max heap suitable for priority queues, and hash tree-based collections. These implementations are organized into thematic modules, allowing developers to import only the data structures they need.
Developers should adopt this package when their applications require collection types with specific performance characteristics or ordering guarantees not provided by the standard library. Projects that need to preserve insertion order in sets or dictionaries, require fixed-capacity or uniquely-held array variants, or benefit from specialized structures like deques or bit sets are good candidates. The package distinguishes itself by offering multiple variants of similar concepts—such as Deque, UniqueDeque, and RigidDeque—each optimized for different ownership and capacity models, giving developers fine-grained control over memory behavior.
The project maintains a clear separation between stable data structures and experimental features. Stable implementations are organized across modules including BasicContainers, DequeModule, OrderedCollections, BitCollections, HeapModule, and HashTreeCollections. Experimental features are available through package traits, allowing developers to opt into preview functionality for unstable containers, hashed containers, and sorted collections. The project defines a public API contract and specifies minimum Swift toolchain version requirements. Contribution guidelines distinguish between bug fixes, small enhancements, and proposals for new data structures, with a documented branching strategy for development.