Commit Graph
739 Commits
Author SHA1 Message Date
Karoy Lorentey dbc2866bb5 [Heap] removeAll(where:): Fix exception safety 2025-05-15 21:39:55 -07:00
Dakshin Devanand c7c38028cd Add Heap.removeAll(where:) 2025-05-15 21:39:50 -07:00
Karoy Lorentey ace6afa65b Merge pull request #455 from DakshinD/heap-max-func
Align Heap._UnsafeHandle min/maxValue tie-breaking with Swift.min/max
2025-05-15 21:08:49 -07:00
Karoy Lorentey 225159599d [Heap] Fix remaining tie break inconsistency in popMax 2025-05-15 17:34:16 -07:00
Karoy Lorentey d93a6ab8a1 [Heap] Follow the spelling of stdlib’s min/max; add note explaining expectations
The existing expressions had the same effect, but they used different operators (`<=` instead of `<` and `>` instead of `>=`). The distinction is usually irrelevant, but there is no reason not to just follow what the stdlib is doing exactly.
2025-05-15 17:30:25 -07:00
Karoy Lorentey e63f444a26 Merge pull request #456 from 3405691582/nocapacity
ManagedBuffer.capacity is unavailable on OpenBSD.
2025-05-15 14:57:30 -07:00
Karoy Lorentey 42fd02dd1a Merge pull request #452 from pm-dev/ordered-set-appending
[OrderedSet] Add `OrderedSet.appending(contentsOf:)`
2025-05-15 14:19:55 -07:00
Evan Wilde a7fec81fc4 Use full module triple for swift modules
Install swiftmodules with the full module triple expected by the
compiler instead of attempting to compute the correct architecture name
in CMake.
2025-05-12 20:34:02 -07:00
3405691582andKaroy Lorentey 25509c0b88 Update Sources/HashTreeCollections/HashNode/_HashTreeStatistics.swift
Co-authored-by: Karoy Lorentey <klorentey@apple.com>
2025-05-02 17:04:54 -04:00
3405691582 9523b6a85d ManagedBuffer.capacity is unavailable on OpenBSD.
ManagedBuffer.capacity depends on malloc introspection (e.g.,
`malloc_size`), which is not available on this platform -- and is thus
marked as such.

Here, _HashNode.Storage is a ManagedBuffer. Thankfully, the uses of
.capacity are fairly limited: one for statistic purposes, which we just
completely omit on the platform, and the other, setting a minimum
capacity in the header by the buffer's .capacity; the alternative being
setting that minimum capacity directly.
2025-03-29 13:12:52 -04:00
Dakshin Devanand 5edd1be23c Make Heap._UnsafeHandle min/maxValue tie-breaker consistent with Swift.min/max 2025-03-08 10:08:39 -06:00
Peter Meyers e00243217e [OrderedSet] Add OrderedSet.appending(contentsOf:) 2025-02-20 15:34:04 -05:00
김봉균 4450b7c622 fix typo 2025-01-07 11:26:40 +09:00
Karoy Lorentey 84087c786e [BTree] Rephrase some comments 2024-10-21 11:03:33 -07:00
Karoy Lorentey 5dd817c33d Merge branch 'release/1.1' 2024-08-05 20:10:26 -07:00
Karoy Lorentey 293314a584 Merge pull request #403 from quokkaKyu/release/1.1
add 'final' keyword to class
2024-07-18 14:38:35 -07:00
Karoy Lorentey 5e1fe6e8f0 [BigString] Fix accidentally quadratic BigString.init
When ingesting a `String` instance, `BigString` assumes that the input string has a reasonably efficient UTF-8 view.

Unfortunately, that is very much not the case when the input happens to be backed by a bridged NSString object — it appears that in this case, the ingester loop invokes some operation(s) with linear complexity in the size of the entire input, rendering the ingester’s overall complexity quadratic.

The BigString ingester is only expected to operate within a single chunk at the time. It’s unclear precisely which operation triggers the quadratic behavior; ideally we should figure it out and resolve it with a more targeted fix.

In the meantime, a blunt stopgap fix is to force-transcode the input string to UTF-8 at the time the ingester is initialized. This unnecessarily wastes some (temporary) memory on holding the transcoded string, but it avoids the quadratic cliff.
2024-07-15 13:13:44 -07:00
quokkakyu 6b8276e252 add 'final' keyword to class 2024-07-15 09:27:27 +09:00
Jeremy Schonfeld 3d2dc41a01 [CMake] Reduce the size of the _FoundationCollections module (#395) 2024-07-08 11:23:21 -07:00
Jeremy Schonfeld 3e120b48bb [CMake] Reduce path lengths in single-module build (#392)
* Eliminate relative paths from the cmake single-module build

* Attempt to reduce length of paths in single module build
2024-06-26 08:39:11 -07:00
Jeremy Schonfeld af8349c392 Install the foundation toolchain module during the static swift build (#391) 2024-06-18 15:09:16 -07:00
Karoy Lorentey ad79ce5b6a Merge branch 'release/1.1'
# Conflicts:
#	.swiftci/5_10_ubuntu2204
#	.swiftci/5_7_ubuntu2204
#	.swiftci/5_8_ubuntu2204
#	.swiftci/5_9_ubuntu2204
#	.swiftci/nightly_6_0_macos
#	.swiftci/nightly_6_0_ubuntu2204
#	.swiftci/nightly_main_macos
#	.swiftci/nightly_main_ubuntu2204
2024-06-05 10:28:47 -07:00
Jeremy Schonfeld ee97538f5b Add Single Module Build Mode to CMake for Foundation (#385)
* Add new single-module and foundation-toolchain-module modes to CMake build

* Fix allowable client flag syntax
2024-06-03 16:15:50 -07:00
Karoy Lorentey a0b839d7de [Rope] Fix copy-on-write violation in Rope.join
Rope.join has a logic error where it fails to properly ensure uniqueness of child node references before zipping the two b-trees together.

rdar://128450202
2024-05-31 17:12:07 -07:00
Karoy Lorentey 35d5746117 Rename _CollectionsUtilities to InternalCollectionsUtilities
We are forced to do this due to an Xcode issue (#364) with underscored module names.

This module remains unstable, despite the removal of the underscore. Directly importing it from outside the package remains unsupported. This module and/or its entire contents may go away or change in incompatible ways in any future swift-collections release.
2024-05-29 14:00:13 -07:00
Karoy Lorentey ead6314a1c [Deque]: Fix bogus assert in Deque._Storage._ensureUnique
A non-unique reference to a storage instance can legitimately become unique at any point, due to other references (say, held, by another thread) getting destroyed.

`Deque`’s `ensureUnique` implementation currently invokes the uniqueness check two times in quick succession, expecting it to return false both times. In rare circumstances, this can lead to a spurious trap in concurrent environments.

Fix this by avoiding calling `isUnique` more than once.
2024-05-24 13:13:00 -07:00
Charles Hu 89b3ca0146 Fix the incorrect file name in OrderedCollections cmake file
- Currently OrderedCollections cmake incorrectly list "Utilities/_UnsafeBitSet.swift" instead of "Utilities/_UnsafeBitset.swift", causing build failures
2024-05-21 19:24:08 -07:00
Charles Hu ba5154b934 Rename RopeModule to _RopeModule in CMakeLists.txt to match Package.swift 2024-04-30 11:23:27 -07:00
Karoy Lorentey e004cd36fa Merge branch 'release/1.1' into merge.1.1→main
# Conflicts:
#	CMakeLists.txt
#	README.md
2024-02-07 17:35:40 -08:00
Karoy Lorentey 94cf62b3ba Merge pull request #352 from vanvoorden/vanvoorden/tree-dictionary-keys-equality
[TreeDictionary][Keys] Add Equatable and Hashable Conformance to TreeDictionary.Keys
2024-02-06 18:58:46 -08:00
Dimitris Apostolou 7539583245 Fix typos
# Conflicts:
#	Sources/SortedCollections/BTree/_BTree+BidirectionalCollection.swift
#	Sources/SortedCollections/BTree/_BTree+UnsafeCursor.swift
#	Sources/SortedCollections/BTree/_BTree.Builder.swift
#	Sources/SortedCollections/BTree/_BTree.swift
#	Sources/SortedCollections/BTree/_Node.Splinter.swift
#	Sources/SortedCollections/BTree/_Node.Storage.swift
#	Sources/SortedCollections/BTree/_Node.UnsafeHandle+Insertion.swift
#	Sources/SortedCollections/BTree/_Node.swift
#	Tests/SortedCollectionsTests/BTree/Node+Join Tests.swift
2024-02-06 15:52:26 -08:00
Rick van Voorden 3abf60adae wip tree dictionary keys hashable 2024-02-06 14:21:29 -08:00
Dimitris Apostolou ab744afc39 Fix typos 2024-02-04 20:35:42 +02:00
Karoy Lorentey 8e64f064f5 [Xcode] Update the Xcode project 2024-02-02 22:02:05 -08:00
Karoy Lorentey e21c18c05c Update Swift version references in docs 2024-02-02 16:20:22 -08:00
Karoy Lorentey ffa4a58bc1 Update remaining copyright notices 2024-02-02 16:20:22 -08:00
Karoy Lorentey 5bce3c9ceb [RopeModule] Adopt _specialize and extend adoption of modern generic decl syntax 2024-02-02 16:20:21 -08:00
Karoy Lorentey 64b286d63d [OrderedCollections] Update copyright notices 2024-02-02 16:20:21 -08:00
Karoy Lorentey f59aeeb56a [OrderedCollections] Adopt modern generic declaration syntax and _specialize 2024-02-02 16:20:21 -08:00
Karoy Lorentey 540348f147 [Heap] Update copyright notices 2024-02-02 16:20:21 -08:00
Karoy Lorentey 3c99c84286 [Heap] Clean up description
- Don’t print the type name
- Include some information identifying the heap instance
2024-02-02 16:20:21 -08:00
Karoy Lorentey 37e66d0e49 [Heap] Modernize generic declaration syntax 2024-02-02 16:20:21 -08:00
Karoy Lorentey c33444df6f [HashTreeCollections] Update copyright notices 2024-02-02 16:20:20 -08:00
Karoy Lorentey d1e52208a3 [HashTreeCollections] Modernize declaration syntax of generic functions; adopt _specialize(_:for:) 2024-02-02 16:20:19 -08:00
Karoy Lorentey a5117b49f4 [Collections] Add a note why _RopeModule isn’t reexported 2024-01-31 19:34:37 -08:00
Karoy Lorentey 55db6d936c Remove workaround for SR-14663
Our updated minimum toolchain requirement is Swift 5.7, and the stdlib in that version has the fix included.

We’ve seen reports that the bug may not deploy back in all cases to earlier OS releases, but it still seems worth trying to remove the workaround, as it has some undesirable runtime implications.
2024-01-31 19:34:37 -08:00
Karoy Lorentey d45ccb0028 [BitSet] Fix missing import 2024-01-31 19:34:37 -08:00
Karoy Lorentey a0da2df799 [BitArray] Update LosslessStringConvertible initializer to accept new description format 2024-01-31 19:34:36 -08:00
Karoy Lorentey ae641c3d5d [BitArray] Fix description implementation; update tests 2024-01-31 19:34:36 -08:00
Karoy Lorentey e01391e562 [BitArray] Fix logic error in toggleAll()
D’oh — lucky the test coverage caught this; unlucky that the test wasn’t deterministic, and the chances of this occurring were quite low.
2024-01-31 19:34:36 -08:00