Commit Graph
74 Commits
Author SHA1 Message Date
Karoy Lorentey 3c6cb8cd56 Update CMake configuration 2022-10-19 17:35:13 -07:00
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 5aed92655d [CMake] Update CMake build configuration 2022-10-11 13:11:37 -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 17b6c8f5c7 [OrderedDictionary] OrderedDictionary, .Iterator, .Values, .Elements, .Elements.SubSequence, .Elements.SubSequence.Iterator: Explicitly conform to Sendable when Element is Sendable 2022-10-05 11:44:06 -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 de31437ee5 Merge branch 'feature/PersistentCollections' into release/1.1 2022-09-19 16:02:51 -07:00
Karoy Lorentey 9f38e7424b [OrderedDictionary] Doc fix 2022-09-16 16:07:33 -07:00
Karoy Lorentey c9ca59fbb9 [PersistentCollections] Improved storage representation
- Switch to using `ManagedBuffer` to represent node storage. This has
  useful performance benefits, but it significantly complicates access
  to node data. We no longer have direct access to the underlying raw
  storage: everything needs to go through closures passed to
  `ManagedBuffer.withUnsafeMutablePointers`.

- Introduce `struct _Node` and `struct _Node.UnsafeHandle` to
  represent a (strong) reference to a hash tree node, and a
  convenient handle for node storage, respectively. Use these instead
  of directly accessing the ManagedBuffer object, whenever feasible.

- Implement separate paths for in-place mutations vs copy-on-write
  operation, optimizing both flavors.

- Go to great lengths to eliminate unnecessary retain-release traffic,
  whenever possible.

- Push subtree counts into parent nodes by moving the corresponding
  field from the node header into the `_Node` struct. (This results in
  a cool ~20x speedup for jumping around in the tree by integer
  offsets.)

- Implement a type-punned empty root singleton, to allow creating
  empty trees without allocating anything.
2022-09-13 23:48:54 -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 9a9d7d87d8 Merge branch 'release/1.0'
# Conflicts:
#	.swiftpm/xcode/xcshareddata/xcschemes/swift-collections-Package.xcscheme
#	Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/Collections.xcscheme
#	Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/OrderedCollections.xcscheme
#	Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/swift-collections-Package.xcscheme
2022-09-02 15:30:31 -07:00
Karoy Lorentey a9e2276472 Merge pull request #168 from lorentey/cherry-pick-1.0.3
Cherry pick recent fixes to release/1.0 in preparation of tagging 1.0.3
2022-09-01 17:21:25 -07:00
Karoy Lorentey 71aa4a39ae [OrderedDictionary] Resolve spurious(?) call-site ambiguities 2022-08-31 17:57:24 -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 d0f05d5cf5 [OrderedCollection] Use standard temp allocation facility, if available
The 5.6 stdlib introduced a new facility for temporary allocations
that promises better performance than direct allocations. Use it when
the toolchain version is above 5.6.

(cherry picked from commit ddb6d141b3)
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 a6cf763c32 Merge pull request #162 from apple/fix-name-lookup-weirdness
[OrderedSet] Work around weird name lookup issue in compiler
2022-08-17 18:03:36 -07:00
Karoy Lorentey 1071b37294 [OrderedSet] Work around weird name lookup issue in compiler
Resolves #157.
2022-08-17 17:37:53 -07:00
Karoy Lorentey 8cc9d2200c Merge pull request #160 from apple/use-temp-alloc-facility
[OrderedCollection] Use standard temp allocation facility, if available
2022-08-17 15:18:25 -07:00
Karoy Lorentey ddb6d141b3 [OrderedCollection] Use standard temp allocation facility, if available
The 5.6 stdlib introduced a new facility for temporary allocations
that promises better performance than direct allocations. Use it when
the toolchain version is above 5.6.
2022-08-17 13:52:00 -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
Karoy Lorentey 6cb037037d [OrderedDictionary][doc] Update docs for merge/filter operations
Resolves #145
2022-05-23 16:17:35 -07:00
Karoy Lorentey 50e6a1ac71 [OrderedDictionary] Fix type inference issue with OrderedDictionary.init(grouping:by:)
This adds a new overload to help the type checker infer `[S.Element]` as the default `Value` type.

Resolves #139.
2022-02-08 14:16:18 -08: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 e959a64528 [OrderedDictionary] Add some more _checkInvariants() calls 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
Karoy Lorentey 9d4bb8cdf8 [OrderedDictionary] Remove deprecated API
Mark the deprecated `subscript(offset:)` and `modifyValue(...)` APIs unavailable and replace their bodies with fatalError().
2021-09-03 19:11:29 -07:00