A PHP library for representing and manipulating collections, with typed collection and map classes inspired by the Java Collections Framework.
apple/swift-collections
Swift package providing commonly used data structures such as deques, heaps, ordered sets and dictionaries, and bit sets for Swift developers.
- Stars
- 4,547
- Forks
- 436
- Open issues
- 70
- Last commit
- 18 hours ago
What is it?
Swift Collections is a Swift package of data structure implementations that extend the standard library's Array, Set, and Dictionary types. It is organized into thematic modules, including DequeModule for double-ended queues backed by a ring buffer, HeapModule for a min-max heap usable as a priority queue, and OrderedCollections for OrderedSet and OrderedDictionary, which preserve insertion order.
Other modules cover BitCollections (BitSet and BitArray for more compact bit-based storage), HashTreeCollections (persistent hashed TreeSet and TreeDictionary built on CHAMP tries that share unchanged parts across copies), and BasicContainers (ownership-aware UniqueArray and RigidArray). The Collections module re-exports the main stable types through a single import.
The package follows semantic versioning and requires a recent Swift toolchain, with the minimum version listed per release. Experimental features such as SortedCollections, Robin Hood hashed containers, and container protocol previews are gated behind opt-in package traits and are not stable API.
Key features
- 01Deque, heap, OrderedSet and OrderedDictionary types for common collection needs.
- 02BitSet and BitArray for compact bit-based storage.
- 03Persistent TreeSet and TreeDictionary that share unchanged parts across copies.
- 04Single Collections import exposes the main stable types.
- 05Semantic versioning with a documented minimum Swift toolchain per release.
Use cases
- Maintaining insertion order in a Swift dictionary or set without writing custom code.
- Using a priority queue or double-ended queue in a Swift server or app.
- Storing large sets of integers or booleans more compactly with bit-based types.
- Sharing immutable snapshots of a dictionary across threads or states with persistent trees.
Quick start
- 1
Add swift-collections as a package dependency in your Package.swift, as described in the README's usage section
Things to know
- Experimental features behind package traits are unstable and may change or be removed without notice.
- Requires a Swift toolchain, so it is only useful for Swift projects.
Topics
FAQ
- What is swift-collections?
- Swift package providing commonly used data structures such as deques, heaps, ordered sets and dictionaries, and bit sets for Swift developers. Swift Collections is a Swift package of data structure implementations that extend the standard library's Array, Set, and Dictionary types. It is organized into thematic modules, including DequeModule for double-ended queues backed by a ring buffer, HeapModule for a min-max heap usable as a priority queue, and OrderedCollections for OrderedSet and OrderedDictionary, which preserve insertion order.
- Is swift-collections free to use? What license does it have?
- swift-collections is open source under the Apache-2.0 license. Check the license terms before using it in commercial products.
- Is swift-collections still maintained?
- Actively maintained. The last commit to swift-collections was on Nov 6, 2026.
- What can I use swift-collections for?
- Maintaining insertion order in a Swift dictionary or set without writing custom code. Using a priority queue or double-ended queue in a Swift server or app. Storing large sets of integers or booleans more compactly with bit-based types. Sharing immutable snapshots of a dictionary across threads or states with persistent trees.
- How do I install swift-collections?
- Add swift-collections as a package dependency in your Package.swift, as described in the README's usage section
- Where can I get swift-collections?
- The source code and installation instructions are on GitHub: https://github.com/apple/swift-collections
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A Java library for compressed bitmaps (Roaring bitmaps) that supports fast set operations on integer sets with less memory than other formats.
A curated awesome-list of Flutter libraries, plugins, tutorials, articles, and example apps, organized by topic.
Self-hosted collection manager for tracking physical collections of any kind, such as books, DVDs, stamps or games.
Google's core Java libraries, adding collections like multimap and multiset, graph structures, and utilities for concurrency, I/O, hashing and strings.
A browser-based web app for encryption, encoding, compression, hashing and data analysis, often called the Cyber Swiss Army Knife.