Files

2.3 KiB

Collections

Swift Collections is an open-source package of data structure implementations for the Swift programming language.

Overview

Modules

  • Basic Containers - Defines UniqueArray and RigidArray, noncopyable array variants trading some of Array's flexibility for more predictable performance.
  • Bit Collections - Defines BitSet and BitArray, dynamic bit collections.
  • Deque Module - Defines Deque<Element>, a double-ended queue backed by a ring buffer. Deques are range-replaceable, mutable, random-access collections.
  • Heap Module - Defines Heap, a min-max heap backed by an array, suitable for use as a priority queue.
  • Ordered Collections - Defines OrderedSet<Element>, a variant of the standard Set where the order of items is well-defined and items can be arbitrarily reordered. Uses a ContiguousArray as its backing store, augmented by a separate hash table of bit packed offsets into it. OrderedDictionary<Key, Value>, an ordered variant of the standard Dictionary, providing similar benefits.
  • Hash Tree Collections - Defines TreeSet and TreeDictionary, persistent hashed collections implementing Compressed Hash-Array Mapped Prefix Trees (CHAMP). These work similar to the standard Set and Dictionary, but they excel at use cases that mutate shared copies, offering dramatic memory savings and radical time improvements.
  • Trailing Elements Module - Defines TrailingArray, a low-level, ownership-aware variant of ManagedBuffer, for interoperability with C constructs that consist of a fixed-size header directly followed by variable-size storage buffer.

Additional Resources