# apple/swift-collections

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/apple-swift-collections).**

4,438 stars · 390 forks · Swift · Apache-2.0

## Links

- GitHub: https://github.com/apple/swift-collections
- awesome-repositories: https://awesome-repositories.com/repository/apple-swift-collections.md

## Topics

`collection` `container` `deque` `dequeue` `hash` `ordered-dictionary` `ordered-set` `queue` `sequence`

## Description

This library provides a collection of specialized data structures for the Swift language that extend the standard library with advanced container types. It includes implementations for double-ended queues using ring-buffers, priority queues based on min-max heaps, and memory-efficient bit-set and bit-array storage for boolean values.

The project features ordered collections that maintain elements in sorted order via B-tree implementations, as well as persistent sets and dictionaries that use compressed prefix trees to share data between mutated copies. It also provides specialized containers that preserve insertion order.

The library covers a range of capabilities including low-level memory management for C buffers and noncopyable values, fixed-capacity storage, and the use of robin hood hashing to optimize memory utilization and lookup speeds.

## Tags

### Data & Databases

- [High-Performance Containers](https://awesome-repositories.com/f/data-databases/high-performance-collection-processing/high-performance-containers.md) — Provides a comprehensive suite of high-performance Swift data structures, including priority queues and deques.
- [Persistent Collections](https://awesome-repositories.com/f/data-databases/data-collections-datasets/persistent-collections.md) — Implements persistent collections using compressed prefix trees to share data between mutated copies. ([source](https://cdn.jsdelivr.net/gh/apple/swift-collections@main/README.md))
- [Priority Queues](https://awesome-repositories.com/f/data-databases/data-structure-implementations/optimized-data-structures/priority-queues.md) — Implements priority queues using a min-max heap backed by an array for efficient priority-based retrieval. ([source](https://cdn.jsdelivr.net/gh/apple/swift-collections@main/README.md))
- [Insertion-Order Maps](https://awesome-repositories.com/f/data-databases/insertion-order-maps.md) — Provides specialized set and dictionary variants that preserve the original sequence of inserted elements. ([source](https://cdn.jsdelivr.net/gh/apple/swift-collections@main/README.md))
- [B-Tree](https://awesome-repositories.com/f/data-databases/storage-engines/b-tree.md) — Implements B-tree based sorted sets and dictionaries for logarithmic search and mutation performance.
- [Fixed-Capacity Containers](https://awesome-repositories.com/f/data-databases/fixed-capacity-containers.md) — Provides arrays, sets, and dictionaries with strictly defined maximum capacities. ([source](https://cdn.jsdelivr.net/gh/apple/swift-collections@main/README.md))
- [Robin Hood Hashing](https://awesome-repositories.com/f/data-databases/hash-maps/key-mapping-functions/hash-table-implementations/robin-hood-hashing.md) — Uses a robin hood hashing strategy in hashed containers to optimize memory utilization and lookup speeds.
- [Memory Optimization Strategies](https://awesome-repositories.com/f/data-databases/memory-optimization-strategies.md) — Optimizes memory utilization and lookup stability using hashed containers with a robin hood distribution strategy. ([source](https://cdn.jsdelivr.net/gh/apple/swift-collections@main/README.md))
- [In-Memory B-Trees](https://awesome-repositories.com/f/data-databases/storage-engines/b-tree/in-memory-b-trees.md) — Ships sorted sets and dictionaries powered by a B-tree implementation for efficient in-memory lookups.

### Programming Languages & Runtimes

- [Swift Collection Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/swift-collection-libraries.md) — Provides a comprehensive suite of specialized data structures and advanced container types for the Swift language.
- [Double-Ended Queues](https://awesome-repositories.com/f/programming-languages-runtimes/double-ended-queues.md) — Implements double-ended queues using a ring-buffer to provide constant-time insertions and removals from both ends.
- [Ordered Collections](https://awesome-repositories.com/f/programming-languages-runtimes/ordered-collections.md) — Provides sequential data structures that maintain element order and support integer-based indexing.
- [Persistent Data Structures](https://awesome-repositories.com/f/programming-languages-runtimes/persistent-data-structures.md) — Implements collections and containers that preserve previous versions through structural sharing to ensure immutability.
- [Sorted Collection Libraries](https://awesome-repositories.com/f/programming-languages-runtimes/sorted-collection-libraries.md) — Offers collection types that maintain elements in strictly increasing order via B-tree implementations. ([source](https://cdn.jsdelivr.net/gh/apple/swift-collections@main/README.md))
- [Memory Efficiency Strategies](https://awesome-repositories.com/f/programming-languages-runtimes/memory-efficient-runtimes/memory-efficiency-strategies.md) — Implements bit maps and specialized hashed containers to reduce memory overhead in Swift applications.

### Education & Learning Resources

- [Persistent](https://awesome-repositories.com/f/education-learning-resources/educational-resources/algorithms-theory-academics/cs-theory-foundations/data-structure-implementations/data-structures/prefix-trees/persistent.md) — Ships persistent sets and dictionaries based on compressed prefix trees for efficient data sharing.

### Operating Systems & Systems Programming

- [C Memory Management](https://awesome-repositories.com/f/operating-systems-systems-programming/c-memory-management.md) — Provides low-level memory management for C buffers to enable safe data exchange with system components.
- [Noncopyable Value Wrappers](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/process-and-memory-management/memory-management/allocation-strategies/dynamic-memory-allocation/memory-allocation-tracers/heap-allocation-strategies/dynamic-heap-allocators/noncopyable-value-wrappers.md) — Implements heap-allocated wrappers to manage the memory and ownership of noncopyable Swift values.
- [Low-Level Swift Memory Management](https://awesome-repositories.com/f/operating-systems-systems-programming/low-level-swift-memory-management.md) — Handles C buffers and noncopyable values to safely manage heap allocation and system interoperability.

### Software Engineering & Architecture

- [Priority Queues](https://awesome-repositories.com/f/software-engineering-architecture/queue-implementations/priority-queues.md) — Provides a priority queue implementation based on a min-max heap for rapid retrieval of extremum values.
- [Noncopyable Value Wrappers](https://awesome-repositories.com/f/software-engineering-architecture/wrapped-value-inspection/noncopyable-value-wrappers.md) — Wraps noncopyable values in heap-allocated containers to manage their memory and ownership. ([source](https://cdn.jsdelivr.net/gh/apple/swift-collections@main/README.md))
- [Bit-Packed Storage](https://awesome-repositories.com/f/software-engineering-architecture/memory-layout-optimizations/bit-packed-storage.md) — Provides memory-efficient bit-set and bit-array implementations for optimizing boolean storage. ([source](https://cdn.jsdelivr.net/gh/apple/swift-collections@main/README.md))
