Swift Collections is an open-source package of data structure implementations for the Swift programming language.
Read more about the package, and the intent behind it, in the announcement on swift.org.
The package currently provides the following implementations:
Deque<Element>, a double-ended queue backed by a ring buffer. Deques are range-replaceable, mutable, random-access collections.
OrderedSet<Element>, a variant of the standard
Setwhere the order of items is well-defined and items can be arbitrarily reordered. Uses a
ContiguousArrayas 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.
The following data structures are currently being worked on but they aren’t ready for inclusion in a tagged release:
PriorityQueue, min-max heaps backed by an array.
SortedDictionary, sorted collections backed by in-memory persistent b-trees.
HashMap, persistent hashed collections implemented as Compressed Hash-Array Mapped Prefix-Trees (CHAMP).
BitSet, dynamic bit vectors.
SparseSet, a constant time set construct, trading off memory for speed.
Swift Collections uses the same modularization approach as Swift Numerics: it provides a standalone module for each thematic group of data structures it implements. For instance, if you only need a double-ended queue type, you can pull in only that by importing
OrderedDictionary share much of the same underlying implementation, so they are provided by a single module, called
OrderedCollections. However, there is also a top-level
Collections module that gives you every collection type with a single import statement:
import Collections var deque: Deque<String> = ["Ted", "Rebecca"] deque.prepend("Keeley") deque.append("Nathan") print(deque) // ["Keeley", "Ted", "Rebecca", "Nathan"]
Mobile App Development Best Practices – 02.10
Data.ai has summarized the interim results of the year – and once again we have a record. Annual consumer spending...
How to Use Kotlin’s Timing API
Kotlin’s Timing API is stable as of Kotlin 1.9, and it offers some great ways to both measure and specify...
Candy Crush made $20 billion
King attributes its huge success to several factors, including not only the games themselves, but also the company's commitment to...
FittedSheets – Bottom sheets for iOS.
This project is to enable easily presenting view controllers in a bottom sheet that supports scrollviews and multiple sizes. Contributions...
ComposeFadingEdges – Android Compose UI with fading edges
The ComposeFadingEdges is a powerful Android Compose library that seamlessly incorporates customisable fading edges with horizontal or vertical orientations, static or scrollable...
Mobile Consumer Spend Surpasses $100 Billion in Record Time in 2023
Positive growth in mobile consumer spend continued in Q3 2023 at a solid 3.7% year-over-year. Downloads declined slightly over the...