Commit Graph
49 Commits
Author SHA1 Message Date
Karoy Lorentey 381cf5d17e Merge branch 'release/1.0' into release/1.1 2022-10-19 15:50:34 -07:00
Karoy Lorentey 734730d724 [OrderedSet] Split SetAlgebra predicates into individual files
This is to match the layout of all the other
SetAlgebra implementations in this package.
2022-10-19 15:20:30 -07:00
Karoy Lorentey 5dfd51238c [OrderedSet] Review, test, fix, and document set relation predicates 2022-10-19 15:20:30 -07:00
Karoy Lorentey 51a1554f89 Introduce _UniqueCollection & _SortedCollection
These marker-like protocols will allow certain
generic operations to get a performance boost
if the passed-in value happens to be guaranteed
to contain unique elements or to be sorted.

Also, review API checker protocols for Sets and
sorted collections and adjust things as needed.

BitSet gains custom implementations for min()
and max() as part of these improvements.
2022-10-19 01:40:06 -07:00
Karoy Lorentey f76630db8e [Internals] Add missing internal checking predicates & docs for all 2022-10-18 22:13:19 -07:00
Karoy Lorentey 2b4ec22949 [OrderedSet] Small doc updates/fixes 2022-10-18 22:03:29 -07:00
Karoy Lorentey 51604cd196 [OrderedCollections] Oops, restore custom wording for areInIncreasingOrder variants 2022-10-12 15:11:57 -07:00
Karoy Lorentey a624614717 [OrderedCollections] Document that sort is stable (as of SE-0372) 2022-10-11 13:38:10 -07:00
Karoy Lorentey 8b06c61c7e Merge branch 'release/1.0' into release/1.1 2022-10-11 11:24:28 -07:00
Karoy Lorentey 3d11356006 [OrderedSet] Move RAC utilities to _CollectionsUtilities module 2022-10-09 20:11:51 -07:00
Karoy Lorentey 82aae27cff [OrderedSet] OrderedSet, .SubSequence, .UnorderedView, .UnstableInternals: Explicitly conform to Sendable when Element is Sendable 2022-10-05 11:39:03 -07:00
Karoy Lorentey 66651795d8 [OrderedSet] Tiny doc fixes for isSuperset. 2022-09-29 17:56:55 -07:00
Karoy Lorentey 19c9f282c9 Delete _FastMembershipCheckable
We don’t actually need this, as `_customContainsEquatableElement`
returning non-nil is a perfectly suitable indication that containment
checking is fast.
2022-09-29 17:37:48 -07:00
Karoy Lorentey 3d10964905 [PersistentSet] Flesh out isSubset/iSuperset/isDisjoint/etc overloads (untested)
This adds an experimental _FastMembershipCheckable protocol to speed
up these relationship predicates when possible — having separate
overloads for each known collection with a fast containment check
is not going to scale for long.

This commit also introduces a set of isEqual(to:) methods that
generalize ==.
2022-09-24 17:02:16 -07:00
Karoy Lorentey 12e3867ccb [Collections] Allow determining if internal checking is enabled
In the benchmark target, complain loudly if consistency checks
are enabled.
2022-09-19 21:25:07 -07:00
Karoy Lorentey 77edbef16d [_CollectionsUtilities] Restore original debug descriptions 2022-09-13 23:45:22 -07:00
Karoy Lorentey dd76591970 [_CollectionsUtilities] New module. Use it to unify description/debugDescription implementations 2022-09-12 12:47:04 -07:00
Karoy Lorentey b379fa7aee [OrderedCollections] Force-inline all _modify accessors
(cherry picked from commit ee1b2de06e)
2022-08-31 17:13:53 -07:00
Karoy Lorentey 6cbecdb467 [OrderedSet] Work around weird name lookup issue in compiler
Resolves #157.

(cherry picked from commit 1071b37294)
2022-08-31 17:13:53 -07:00
Karoy Lorentey ee1b2de06e [OrderedCollections] Force-inline all _modify accessors 2022-08-31 15:31:42 -07:00
Karoy Lorentey c3fdcf746e Merge pull request #163 from ktoso/wip-filter-set
=OrderedSet.filter Attempt to optimize filter impl
2022-08-18 10:52:29 -07:00
Karoy Lorentey 3bf91b1ee4 Remove hash lookups while filtering 2022-08-17 22:57:37 -07:00
Konrad `ktoso` Malawski f56388e4f7 =OrderedSet.filter Attempt to optimize filter impl 2022-08-18 10:28:20 +09:00
Karoy Lorentey 1071b37294 [OrderedSet] Work around weird name lookup issue in compiler
Resolves #157.
2022-08-17 17:37:53 -07:00
Konrad `ktoso` MalawskiandXiaodi Wu 74a800ac53 Apply suggestions from code review
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
2022-08-17 12:21:02 +09:00
Konrad `ktoso` Malawski f8726ce33f checkInvariants 2022-08-17 11:01:03 +09:00
Konrad `ktoso` Malawski 6142869b83 +OrderedSet add filter #158 2022-08-16 20:37:44 +09:00
Károly Lőrentey 074b0ad213 [OrderedSet] Add missing uniqueness check in OrderedSet._insertNew(_:at:in:) 2021-11-11 00:40:01 -08:00
Karoy Lorentey 7f57a0ed1c [OrderedSet][doc] Fix thinko 2021-09-14 11:50:31 -07:00
Karoy Lorentey f69104b507 [OrderedSet] Don't set a default value for the primary initializer's second argument
This will hopefully prevent issues like the one fixed in the previous commit from reoccurring in the future.
2021-09-09 16:44:06 -07:00
Karoy Lorentey e4f62c1520 [OrderedSet] Don't let the unchecked init create large sets with no hash table
In debug builds, the `OrderedSet.init(uncheckedUniqueElements:)` initializer always created a set with no hash table, even if it had an element count >15. This is technically an invariant violation (caught by `_checkInvariants()`), although it generally only triggers (very) slow performance. (The set reverts to linear searching.)
2021-09-09 16:44:06 -07:00
Karoy Lorentey 96100d4b6a [NFC] Cosmetic/doc updates 2021-09-08 21:12:52 -07:00
Karoy Lorentey 1ae008a410 [OrderedSet] Make _checkInvariants public and call it in more operations
It seems useful to be able to manually call `_checkInvariants` while debugging a package issue. This is public as in `public`, not public as in Public API -- it's underscored.
2021-09-08 21:12:52 -07:00
ejmarchant 4c22d00065 Follow stdlib's leading underscore rule (#95) 2021-08-30 15:44:27 -07:00
Karoy Lorentey 56b82b1b7f Freeze some types for consistency with their inlinable initializers
Note: @frozen does *not* mean that we actually consider these struct types frozen. Their layout may arbitrarily change between even minor releases.
2021-08-30 15:31:12 -07:00
ejmarchant 5ff8c003b0 Fix documentation for types conforming to ExpressibleByArrayLiteral or ExpressibleByDictionaryLiteral (#82)
# Conflicts:
#	Sources/PriorityQueueModule/Heap+ExpressibleByArrayLiteral.swift
2021-08-19 19:26:41 -07:00
Rodrigo Kreutz c0549b6284 Fixing a small typo on quick help documentation. (#55) 2021-06-12 12:06:19 -07:00
François Lamboley f6d8f82627 Replace Index with Int where possible (#32) 2021-05-10 16:36:10 -07:00
Kiel Gillard 0096c5b39d Add the @discardableResult attribute to OrderedSet.insert(_:at:) (#21)
* Add the @discardableResult attribute to OrderedSet.insert(_:at:). Fixes #19

* Add the @discardableResult attribute to OrderedSet.updateOrAppend(_).

* Add the @discardableResult attribute to OrderedSet.updateOrInsert(_:at:).
2021-04-13 19:03:56 -07:00
Karoy Lorentey 2d719d75a2 Fix nondeterministic compiler crash in debug builds (#18)
So as it turns out, the Swift compiler’s MergeModules phase (which SwiftPM uses in Debug builds) has a known issue with dependency cycles between separate source files — it rarely triggers, but when it does, swiftc hits an assertion complaining about a deserialization failure.

The v0.0.1 of Swift Collections happens to include such a cycle, but it only triggers the assertion on a small fraction of machines. I don’t yet know what exactly makes it nondeterministic, but it is reproducible by randomly reshuffling the source filenames of the OrderedSet implementation — a couple dozen randomizations will eventually lead to a state where it happens in every build.

The workaround is to put OrderedSet’s Sequence and RandomAccessCollection conformances in the same file. (OrderedSet uses the standard IndexingIterator, which requires a Collection conformance, while Collection itself refines Sequence — I believe this is the dependency cycle that is causing all this problem.)

Unfortunately, until we figure out what triggers the nondeterminism (or until the MergeModules action is replaced with something that actually, you know, works, this issue may keep randomly reoccurring. None of this makes much sense, but here we are. 😝
2021-04-10 00:17:50 -07:00
Karoy Lorentey 9492a283e7 Merge pull request #6 from numist/numist/ordered-set-diffing
Efficient diffing for OrderedSet
2021-04-08 23:10:10 -07:00
Karoy Lorentey 5a2a6841fd Update OrderedSet+ReserveCapacity.swift 2021-04-08 15:40:08 -07:00
Scott Perry 956ea437df Update complexity in headerdoc to match implementation (and simplify per big-O rules) 2021-04-06 09:49:06 -07:00
Scott PerryandKaroy Lorentey 9ffceb3878 Use elements to manifest an Array from an OrderedSet
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2021-04-06 07:44:35 -07:00
Scott Perry 7b37f7892b Add benchmarks and clean up headerdoc 2021-04-05 20:57:32 -07:00
Scott Perry 7401c23c18 Basic implementation of OrderedSet.applying() balancing performance with code complexity 2021-04-05 19:19:28 -07:00
Scott Perry c71b73954e Match style 2021-04-05 19:07:03 -07:00
Scott Perry ed375766aa Initial implementation of diffing (and tests!) for OrderedSet 2021-04-05 18:35:23 -07:00
Karoy Lorentey a2bcac435f Initial import.
Introduce OrderedCollections module
2021-04-05 09:41:00 -07:00