Le raccolte Swift portano nuove strutture di dati in Swift

La Swift Collection è un nuovo pacchetto open source volto ad ampliare la scelta delle strutture dati a disposizione dei programmatori Swift. Va oltre quanto fornito nella libreria standard. Nella versione iniziale deques, Order set e Il dizionario che hai ordinato..
Deques, che sta per deque, è simile a un array, ma supporta inserimenti ed eliminazioni efficienti sia all’inizio che alla fine: [FIFO queue](Https://en.wikipedia.org/wiki/FIFO_(informatica_e_elettronica)). In particolare, secondo il benchmark dell’ingegnere Swift Karoy Lorentey, l’aggiunta all’inizio di un elemento è Deque
Mostra significativi vantaggi in termini di prestazioni rispetto alla stessa operazione di Array
Inizia con una dimensione della raccolta di 32 elementi. Tuttavia, ciò si ottiene assegnando elementi deque a buffer non contigui. Questo lo rende leggermente più lento di una serie di normali operazioni.
Puoi usare prepend
Con un metodo che inserisce un nuovo elemento all’inizio della deque append
Infine inserisci l’elemento. Allo stesso modo, puoi usare popFirst
e popLast
Fai scoppiare l’elemento dalla fine del deque.
OrderedSet
鈻 Make sure each element is unique and provide an efficient membership test.contains
, While maintaining the same order as beforeappend
Edit to set. Lorentey benchmarks show significantly better performance than unordered onesSet
Start with about 64 elements when usedcontains
..OrderedSet
s can easily be passed to a function that expects:Array
Discussion using them.elements
Property.whenSetAlgebra
Needs compatibility,.unordered
The property provides an unordered view of the configured elements.The third collection in the Swift collection is
OrderedDictionary
, This ensures that the elements remain in a user-defined order, while retaining all the desired properties of the dictionary, such as inserts and accesses for a period of time. Again, while you are allowed to operate for a period of timeOrderedDictionary
Slightly higher than if unorderedDictionary
..AnnOrderedDictionary
Consists ofOrderedSet
Key and normalArray
Can be accessed efficiently using elements, and both.keys
And.elements
Property.Swift collections are similar in nature and intent Swift Numerics And Swift algorithm All packages try to provide data structures that are not available in the standard library in a way that may eventually be included through the formula. Rapid evolution process..
The Swift collection is available on GitHub, And contributions are welcome, but must meet stringent standards for reliability, performance, and memory usage, says Lorentey.
JioPhone then arrives at Google Play Console with key specifications 5 things to consider before installing a smart switch CNET Police IT buyers need to force suppliers to prove AI claims Ministry of Health warns about red tide from Panama City Beach to Mexico Beach From Billie Eilish to Bessie Smith: COP26 Climate Playlist Latest Technology News
- JioPhone arriva quindi su Google Play Console con le specifiche chiave 5 cose da considerare prima di installare uno smart switch CNET Gli acquirenti IT della polizia devono costringere i fornitori a dimostrare le affermazioni dell’IA Il Ministero della Salute avverte della marea rossa da Panama City Beach a Mexico Beach Da Billie Eilish a Bessie Smith: playlist sul clima della COP26