From b8ef14f0c05fd81f0a3f146a536753ff95505aea Mon Sep 17 00:00:00 2001 From: Karoy Lorentey Date: Tue, 15 Nov 2022 14:27:11 -0800 Subject: [PATCH] =?UTF-8?q?ShareableHashedCollections=20=E2=86=92=20HashTr?= =?UTF-8?q?eeCollections?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...bleDictionary.json => TreeDictionary.json} | 94 ++-- .../{ShareableSet.json => TreeSet.json} | 524 +++++++++--------- .../ShareableDictionaryBenchmarks.swift | 128 ++--- .../Benchmarks/ShareableSetBenchmarks.swift | 124 ++--- Benchmarks/Sources/benchmark-tool/main.swift | 4 +- .../memory-benchmark/MemoryBenchmarks.swift | 8 +- Package.swift | 12 +- README.md | 8 +- Sources/CMakeLists.txt | 2 +- Sources/Collections/CMakeLists.txt | 2 +- .../Collections.docc/Collections.md | 6 +- .../Extensions/ShareableDictionary.md | 10 +- .../Extensions/ShareableSet.md | 14 +- Sources/Collections/Collections.swift | 2 +- Sources/HashTreeCollections/CMakeLists.txt | 103 ++++ .../Extensions/TreeDictionary.md} | 10 +- .../Extensions/TreeSet.md} | 14 +- .../HashTreeCollections.md} | 6 +- .../Node/_AncestorSlots.swift | 0 .../Node/_Bitmap.swift | 0 .../Node/_Bucket.swift | 0 .../Node/_Hash.swift | 0 .../Node/_HashTreeIterator.swift | 0 .../Node/_HashTreeStatistics.swift | 0 .../Node/_Level.swift | 0 .../Node/_Node+Builder.swift | 0 .../Node/_Node+Debugging.swift | 0 .../Node/_Node+Initializers.swift | 0 .../Node/_Node+Invariants.swift | 0 .../Node/_Node+Lookups.swift | 0 .../Node/_Node+Primitive Insertions.swift | 0 .../Node/_Node+Primitive Removals.swift | 0 .../Node/_Node+Primitive Replacement.swift | 0 .../Node/_Node+Storage.swift | 0 .../_Node+Structural compactMapValues.swift | 0 .../Node/_Node+Structural filter.swift | 0 .../Node/_Node+Structural intersection.swift | 0 .../Node/_Node+Structural isDisjoint.swift | 0 .../Node/_Node+Structural isEqualSet.swift | 0 .../Node/_Node+Structural isSubset.swift | 0 .../Node/_Node+Structural mapValues.swift | 0 .../Node/_Node+Structural merge.swift | 0 .../Node/_Node+Structural subtracting.swift | 0 ..._Node+Structural symmetricDifference.swift | 0 .../Node/_Node+Structural union.swift | 0 .../Node/_Node+Subtree Insertions.swift | 0 .../Node/_Node+Subtree Modify.swift | 0 .../Node/_Node+Subtree Removals.swift | 0 .../Node/_Node+UnsafeHandle.swift | 0 .../Node/_Node.swift | 0 .../Node/_RawNode+UnsafeHandle.swift | 0 .../Node/_RawNode.swift | 0 .../Node/_Slot.swift | 0 .../Node/_Stack.swift | 2 +- .../Node/_StorageHeader.swift | 0 .../Node/_UnmanagedNode.swift | 0 .../Node/_UnsafePath.swift | 0 .../TreeDictionary+Codable.swift} | 6 +- .../TreeDictionary+Collection.swift} | 26 +- .../TreeDictionary+CustomReflectable.swift} | 2 +- .../TreeDictionary+Debugging.swift} | 2 +- .../TreeDictionary+Descriptions.swift} | 6 +- .../TreeDictionary+Equatable.swift} | 2 +- ...nary+ExpressibleByDictionaryLiteral.swift} | 2 +- .../TreeDictionary+Filter.swift} | 6 +- .../TreeDictionary+Hashable.swift} | 2 +- .../TreeDictionary+Initializers.swift} | 20 +- .../TreeDictionary/TreeDictionary+Keys.swift} | 68 +-- .../TreeDictionary+MapValues.swift} | 12 +- .../TreeDictionary+Merge.swift} | 8 +- .../TreeDictionary+Sendable.swift} | 2 +- .../TreeDictionary+Sequence.swift} | 6 +- .../TreeDictionary+Values.swift} | 32 +- .../TreeDictionary/TreeDictionary.swift} | 37 +- .../TreeSet/TreeSet+Codable.swift} | 4 +- .../TreeSet/TreeSet+Collection.swift} | 26 +- .../TreeSet/TreeSet+CustomReflectable.swift} | 2 +- .../TreeSet/TreeSet+Debugging.swift} | 2 +- .../TreeSet/TreeSet+Descriptions.swift} | 6 +- .../TreeSet/TreeSet+Equatable.swift} | 2 +- .../TreeSet+ExpressibleByArrayLiteral.swift} | 2 +- .../TreeSet/TreeSet+Extras.swift} | 4 +- .../TreeSet/TreeSet+Filter.swift} | 6 +- .../TreeSet/TreeSet+Hashable.swift} | 2 +- .../TreeSet/TreeSet+Sendable.swift} | 2 +- .../TreeSet/TreeSet+Sequence.swift} | 6 +- .../TreeSet+SetAlgebra Initializers.swift} | 4 +- .../TreeSet/TreeSet+SetAlgebra basics.swift} | 2 +- ...TreeSet+SetAlgebra formIntersection.swift} | 10 +- ...+SetAlgebra formSymmetricDifference.swift} | 14 +- .../TreeSet+SetAlgebra formUnion.swift} | 14 +- .../TreeSet+SetAlgebra intersection.swift} | 16 +- .../TreeSet+SetAlgebra isDisjoint.swift} | 16 +- .../TreeSet+SetAlgebra isEqualSet.swift} | 6 +- .../TreeSet+SetAlgebra isStrictSubset.swift} | 16 +- ...TreeSet+SetAlgebra isStrictSuperset.swift} | 16 +- .../TreeSet+SetAlgebra isSubset.swift} | 16 +- .../TreeSet+SetAlgebra isSuperset.swift} | 16 +- .../TreeSet+SetAlgebra subtract.swift} | 14 +- .../TreeSet+SetAlgebra subtracting.swift} | 16 +- ...eSet+SetAlgebra symmetricDifference.swift} | 20 +- .../TreeSet/TreeSet+SetAlgebra union.swift} | 18 +- .../TreeSet/TreeSet.swift} | 21 +- .../ShareableHashedCollections/CMakeLists.txt | 103 ---- .../Utilities/DictionaryAPIChecker.swift | 2 +- .../Colliders.swift | 0 .../Hash.swift | 0 .../TreeDictionary Smoke Tests.swift} | 102 ++-- .../TreeDictionary Tests.swift} | 156 +++--- .../TreeDictionary.Keys Tests.swift} | 24 +- .../TreeDictionary.Values Tests.swift} | 6 +- .../TreeHashedCollections Fixtures.swift} | 26 +- .../TreeSet Tests.swift} | 180 +++--- .../Utilities.swift | 18 +- Utils/generate-docs.sh | 2 +- ....xcscheme => HashTreeCollections.xcscheme} | 35 +- 116 files changed, 1126 insertions(+), 1139 deletions(-) rename Benchmarks/Libraries/{ShareableDictionary.json => TreeDictionary.json} (61%) rename Benchmarks/Libraries/{ShareableSet.json => TreeSet.json} (50%) create mode 100644 Sources/HashTreeCollections/CMakeLists.txt rename Sources/{ShareableHashedCollections/ShareableHashedCollections.docc/Extensions/ShareableDictionary.md => HashTreeCollections/HashTreeCollections.docc/Extensions/TreeDictionary.md} (84%) rename Sources/{ShareableHashedCollections/ShareableHashedCollections.docc/Extensions/ShareableSet.md => HashTreeCollections/HashTreeCollections.docc/Extensions/TreeSet.md} (92%) rename Sources/{ShareableHashedCollections/ShareableHashedCollections.docc/ShareableHashedCollections.md => HashTreeCollections/HashTreeCollections.docc/HashTreeCollections.md} (83%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_AncestorSlots.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Bitmap.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Bucket.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Hash.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_HashTreeIterator.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_HashTreeStatistics.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Level.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Builder.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Debugging.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Initializers.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Invariants.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Lookups.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Primitive Insertions.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Primitive Removals.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Primitive Replacement.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Storage.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural compactMapValues.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural filter.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural intersection.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural isDisjoint.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural isEqualSet.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural isSubset.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural mapValues.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural merge.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural subtracting.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural symmetricDifference.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Structural union.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Subtree Insertions.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Subtree Modify.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+Subtree Removals.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node+UnsafeHandle.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Node.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_RawNode+UnsafeHandle.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_RawNode.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Slot.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_Stack.swift (99%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_StorageHeader.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_UnmanagedNode.swift (100%) rename Sources/{ShareableHashedCollections => HashTreeCollections}/Node/_UnsafePath.swift (100%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Codable.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Codable.swift} (97%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Collection.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Collection.swift} (92%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+CustomReflectable.swift => HashTreeCollections/TreeDictionary/TreeDictionary+CustomReflectable.swift} (92%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Debugging.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Debugging.swift} (97%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Descriptions.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Descriptions.swift} (83%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Equatable.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Equatable.swift} (92%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+ExpressibleByDictionaryLiteral.swift => HashTreeCollections/TreeDictionary/TreeDictionary+ExpressibleByDictionaryLiteral.swift} (95%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Filter.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Filter.swift} (92%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Hashable.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Hashable.swift} (93%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Initializers.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Initializers.swift} (95%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Keys.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Keys.swift} (80%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+MapValues.swift => HashTreeCollections/TreeDictionary/TreeDictionary+MapValues.swift} (87%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Merge.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Merge.swift} (97%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Sendable.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Sendable.swift} (90%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Sequence.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Sequence.swift} (93%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Values.swift => HashTreeCollections/TreeDictionary/TreeDictionary+Values.swift} (80%) rename Sources/{ShareableHashedCollections/ShareableDictionary/ShareableDictionary.swift => HashTreeCollections/TreeDictionary/TreeDictionary.swift} (94%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Codable.swift => HashTreeCollections/TreeSet/TreeSet+Codable.swift} (92%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Collection.swift => HashTreeCollections/TreeSet/TreeSet+Collection.swift} (94%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+CustomReflectable.swift => HashTreeCollections/TreeSet/TreeSet+CustomReflectable.swift} (93%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Debugging.swift => HashTreeCollections/TreeSet/TreeSet+Debugging.swift} (98%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Descriptions.swift => HashTreeCollections/TreeSet/TreeSet+Descriptions.swift} (85%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Equatable.swift => HashTreeCollections/TreeSet/TreeSet+Equatable.swift} (96%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+ExpressibleByArrayLiteral.swift => HashTreeCollections/TreeSet/TreeSet+ExpressibleByArrayLiteral.swift} (96%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Extras.swift => HashTreeCollections/TreeSet/TreeSet+Extras.swift} (97%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Filter.swift => HashTreeCollections/TreeSet/TreeSet+Filter.swift} (93%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Hashable.swift => HashTreeCollections/TreeSet/TreeSet+Hashable.swift} (95%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Sendable.swift => HashTreeCollections/TreeSet/TreeSet+Sendable.swift} (86%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+Sequence.swift => HashTreeCollections/TreeSet/TreeSet+Sequence.swift} (91%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra Initializers.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra Initializers.swift} (96%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra basics.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra basics.swift} (99%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formIntersection.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra formIntersection.swift} (93%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formSymmetricDifference.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra formSymmetricDifference.swift} (88%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formUnion.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra formUnion.swift} (91%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra intersection.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra intersection.swift} (90%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isDisjoint.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra isDisjoint.swift} (87%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isEqualSet.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra isEqualSet.swift} (97%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isStrictSubset.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra isStrictSubset.swift} (93%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isStrictSuperset.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra isStrictSuperset.swift} (93%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isSubset.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra isSubset.swift} (91%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isSuperset.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra isSuperset.swift} (89%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra subtract.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra subtract.swift} (87%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra subtracting.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra subtracting.swift} (89%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra symmetricDifference.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra symmetricDifference.swift} (89%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra union.swift => HashTreeCollections/TreeSet/TreeSet+SetAlgebra union.swift} (90%) rename Sources/{ShareableHashedCollections/ShareableSet/ShareableSet.swift => HashTreeCollections/TreeSet/TreeSet.swift} (82%) delete mode 100644 Sources/ShareableHashedCollections/CMakeLists.txt rename Tests/{ShareableHashedCollectionsTests => HashTreeCollectionsTests}/Colliders.swift (100%) rename Tests/{ShareableHashedCollectionsTests => HashTreeCollectionsTests}/Hash.swift (100%) rename Tests/{ShareableHashedCollectionsTests/ShareableDictionary Smoke Tests.swift => HashTreeCollectionsTests/TreeDictionary Smoke Tests.swift} (85%) rename Tests/{ShareableHashedCollectionsTests/ShareableDictionary Tests.swift => HashTreeCollectionsTests/TreeDictionary Tests.swift} (94%) rename Tests/{ShareableHashedCollectionsTests/ShareableDictionary.Keys Tests.swift => HashTreeCollectionsTests/TreeDictionary.Keys Tests.swift} (82%) rename Tests/{ShareableHashedCollectionsTests/ShareableDictionary.Values Tests.swift => HashTreeCollectionsTests/TreeDictionary.Values Tests.swift} (89%) rename Tests/{ShareableHashedCollectionsTests/ShareableHashedCollections Fixtures.swift => HashTreeCollectionsTests/TreeHashedCollections Fixtures.swift} (92%) rename Tests/{ShareableHashedCollectionsTests/ShareableSet Tests.swift => HashTreeCollectionsTests/TreeSet Tests.swift} (83%) rename Tests/{ShareableHashedCollectionsTests => HashTreeCollectionsTests}/Utilities.swift (91%) rename Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/{ShareableHashedCollections.xcscheme => HashTreeCollections.xcscheme} (65%) diff --git a/Benchmarks/Libraries/ShareableDictionary.json b/Benchmarks/Libraries/TreeDictionary.json similarity index 61% rename from Benchmarks/Libraries/ShareableDictionary.json rename to Benchmarks/Libraries/TreeDictionary.json index 6ba966d1..29d697e3 100644 --- a/Benchmarks/Libraries/ShareableDictionary.json +++ b/Benchmarks/Libraries/TreeDictionary.json @@ -1,42 +1,42 @@ { "kind": "group", - "title": "ShareableDictionary Benchmarks", - "directory": "ShareableDictionary", + "title": "TreeDictionary Benchmarks", + "directory": "TreeDictionary", "contents": [ { "kind": "group", - "title": "ShareableDictionary Operations", + "title": "TreeDictionary Operations", "contents": [ { "kind": "chart", "title": "all", "tasks": [ - "ShareableDictionary init(uniqueKeysWithValues:)", - "ShareableDictionary sequential iteration", - "ShareableDictionary sequential iteration, indices", - "ShareableDictionary.Keys sequential iteration", - "ShareableDictionary.Values sequential iteration", - "ShareableDictionary indexing subscript", - "ShareableDictionary subscript, successful lookups", - "ShareableDictionary subscript, unsuccessful lookups", - "ShareableDictionary subscript, noop setter", - "ShareableDictionary subscript, set existing", - "ShareableDictionary subscript, _modify", - "ShareableDictionary subscript, insert, unique", - "ShareableDictionary subscript, insert, shared", - "ShareableDictionary subscript, remove existing, unique", - "ShareableDictionary subscript, remove existing, shared", - "ShareableDictionary subscript, remove missing", - "ShareableDictionary defaulted subscript, successful lookups", - "ShareableDictionary defaulted subscript, unsuccessful lookups", - "ShareableDictionary defaulted subscript, _modify existing", - "ShareableDictionary defaulted subscript, _modify missing", - "ShareableDictionary successful index(forKey:)", - "ShareableDictionary unsuccessful index(forKey:)", - "ShareableDictionary updateValue(_:forKey:), existing", - "ShareableDictionary updateValue(_:forKey:), insert", - "ShareableDictionary random removals (existing keys)", - "ShareableDictionary random removals (missing keys)", + "TreeDictionary init(uniqueKeysWithValues:)", + "TreeDictionary sequential iteration", + "TreeDictionary sequential iteration, indices", + "TreeDictionary.Keys sequential iteration", + "TreeDictionary.Values sequential iteration", + "TreeDictionary indexing subscript", + "TreeDictionary subscript, successful lookups", + "TreeDictionary subscript, unsuccessful lookups", + "TreeDictionary subscript, noop setter", + "TreeDictionary subscript, set existing", + "TreeDictionary subscript, _modify", + "TreeDictionary subscript, insert, unique", + "TreeDictionary subscript, insert, shared", + "TreeDictionary subscript, remove existing, unique", + "TreeDictionary subscript, remove existing, shared", + "TreeDictionary subscript, remove missing", + "TreeDictionary defaulted subscript, successful lookups", + "TreeDictionary defaulted subscript, unsuccessful lookups", + "TreeDictionary defaulted subscript, _modify existing", + "TreeDictionary defaulted subscript, _modify missing", + "TreeDictionary successful index(forKey:)", + "TreeDictionary unsuccessful index(forKey:)", + "TreeDictionary updateValue(_:forKey:), existing", + "TreeDictionary updateValue(_:forKey:), insert", + "TreeDictionary random removals (existing keys)", + "TreeDictionary random removals (missing keys)", ] } ] @@ -50,7 +50,7 @@ "kind": "chart", "title": "init(uniqueKeysWithValues:)", "tasks": [ - "ShareableDictionary init(uniqueKeysWithValues:)", + "TreeDictionary init(uniqueKeysWithValues:)", "Dictionary init(uniqueKeysWithValues:)", "OrderedDictionary init(uniqueKeysWithValues:)", ] @@ -59,7 +59,7 @@ "kind": "chart", "title": "sequential iteration", "tasks": [ - "ShareableDictionary sequential iteration", + "TreeDictionary sequential iteration", "Dictionary sequential iteration", "OrderedDictionary sequential iteration", ] @@ -68,7 +68,7 @@ "kind": "chart", "title": "sequential iteration [Keys]", "tasks": [ - "ShareableDictionary.Keys sequential iteration", + "TreeDictionary.Keys sequential iteration", "Dictionary.Keys sequential iteration", "OrderedDictionary.Keys sequential iteration", ] @@ -77,7 +77,7 @@ "kind": "chart", "title": "sequential iteration [Values]", "tasks": [ - "ShareableDictionary.Values sequential iteration", + "TreeDictionary.Values sequential iteration", "Dictionary.Values sequential iteration", "OrderedDictionary.Values sequential iteration", ] @@ -86,7 +86,7 @@ "kind": "chart", "title": "sequential iteration using indices", "tasks": [ - "ShareableDictionary sequential iteration, indices", + "TreeDictionary sequential iteration, indices", "Dictionary sequential iteration, indices", "OrderedDictionary sequential iteration, indices", ] @@ -95,7 +95,7 @@ "kind": "chart", "title": "indexing subscript", "tasks": [ - "ShareableDictionary indexing subscript", + "TreeDictionary indexing subscript", "Dictionary indexing subscript", "OrderedDictionary indexing subscript", ] @@ -104,7 +104,7 @@ "kind": "chart", "title": "subscript, successful lookups", "tasks": [ - "ShareableDictionary subscript, successful lookups", + "TreeDictionary subscript, successful lookups", "Dictionary subscript, successful lookups", "OrderedDictionary subscript, successful lookups", ] @@ -113,7 +113,7 @@ "kind": "chart", "title": "subscript, unsuccessful lookups", "tasks": [ - "ShareableDictionary subscript, unsuccessful lookups", + "TreeDictionary subscript, unsuccessful lookups", "Dictionary subscript, unsuccessful lookups", "OrderedDictionary subscript, unsuccessful lookups", ] @@ -122,7 +122,7 @@ "kind": "chart", "title": "subscript, insert into unique collection", "tasks": [ - "ShareableDictionary subscript, insert, unique", + "TreeDictionary subscript, insert, unique", "Dictionary subscript, insert, unique", "Dictionary subscript, insert, reserving capacity", "OrderedDictionary subscript, append, unique", @@ -133,7 +133,7 @@ "kind": "chart", "title": "subscript, insert into shared collection", "tasks": [ - "ShareableDictionary subscript, insert, shared", + "TreeDictionary subscript, insert, shared", "Dictionary subscript, insert, shared", "OrderedDictionary subscript, append, shared", ] @@ -142,7 +142,7 @@ "kind": "chart", "title": "subscript, remove existing from unique collection", "tasks": [ - "ShareableDictionary subscript, remove existing, unique", + "TreeDictionary subscript, remove existing, unique", "Dictionary subscript, remove existing, unique", "OrderedDictionary subscript, remove existing, unique", ] @@ -151,7 +151,7 @@ "kind": "chart", "title": "subscript, remove existing from shared collection", "tasks": [ - "ShareableDictionary subscript, remove existing, shared", + "TreeDictionary subscript, remove existing, shared", "Dictionary subscript, remove existing, shared", "OrderedDictionary subscript, remove existing, shared", ] @@ -160,8 +160,8 @@ "kind": "chart", "title": "subscript, _modify existing", "tasks": [ - "ShareableDictionary subscript, _modify", - "ShareableDictionary defaulted subscript, _modify existing", + "TreeDictionary subscript, _modify", + "TreeDictionary defaulted subscript, _modify existing", "Dictionary subscript, _modify", "Dictionary defaulted subscript, _modify existing", "OrderedDictionary subscript, _modify", @@ -173,7 +173,7 @@ "kind": "chart", "title": "index(forKey:), successful index(forKey:)", "tasks": [ - "ShareableDictionary successful index(forKey:)", + "TreeDictionary successful index(forKey:)", "Dictionary successful index(forKey:)", "OrderedDictionary successful index(forKey:)", ] @@ -182,7 +182,7 @@ "kind": "chart", "title": "index(forKey:), unsuccessful index(forKey:)", "tasks": [ - "ShareableDictionary unsuccessful index(forKey:)", + "TreeDictionary unsuccessful index(forKey:)", "Dictionary unsuccessful index(forKey:)", "OrderedDictionary unsuccessful index(forKey:)", ] @@ -191,7 +191,7 @@ "kind": "chart", "title": "updateValue(_:forKey:), existing", "tasks": [ - "ShareableDictionary updateValue(_:forKey:), existing", + "TreeDictionary updateValue(_:forKey:), existing", "Dictionary updateValue(_:forKey:), existing", "OrderedDictionary updateValue(_:forKey:), existing" ] @@ -200,7 +200,7 @@ "kind": "chart", "title": "updateValue(_:forKey:), insert", "tasks": [ - "ShareableDictionary updateValue(_:forKey:), insert", + "TreeDictionary updateValue(_:forKey:), insert", "Dictionary updateValue(_:forKey:), insert", "OrderedDictionary updateValue(_:forKey:), append" ] diff --git a/Benchmarks/Libraries/ShareableSet.json b/Benchmarks/Libraries/TreeSet.json similarity index 50% rename from Benchmarks/Libraries/ShareableSet.json rename to Benchmarks/Libraries/TreeSet.json index 6e09ca2d..4532d99c 100644 --- a/Benchmarks/Libraries/ShareableSet.json +++ b/Benchmarks/Libraries/TreeSet.json @@ -1,7 +1,7 @@ { "kind": "group", - "title": "ShareableSet Benchmarks", - "directory": "ShareableSet", + "title": "TreeSet Benchmarks", + "directory": "TreeSet", "contents": [ { "kind": "group", @@ -12,21 +12,21 @@ "kind": "chart", "title": "operations", "tasks": [ - "ShareableSet init from range", - "ShareableSet init from unsafe buffer", - "ShareableSet sequential iteration", - "ShareableSet successful contains", - "ShareableSet unsuccessful contains", - "ShareableSet insert", - "ShareableSet remove" + "TreeSet init from range", + "TreeSet init from unsafe buffer", + "TreeSet sequential iteration", + "TreeSet successful contains", + "TreeSet unsuccessful contains", + "TreeSet insert", + "TreeSet remove" ] }, { "kind": "chart", "title": "initializers", "tasks": [ - "ShareableSet init from range", - "ShareableSet init from unsafe buffer", + "TreeSet init from range", + "TreeSet init from unsafe buffer", ] }, { @@ -36,66 +36,66 @@ "kind": "chart", "title": "union with Self, distinct", "tasks": [ - "ShareableSet union with Self (0% overlap, distinct)", - "ShareableSet union with Self (25% overlap, distinct)", - "ShareableSet union with Self (50% overlap, distinct)", - "ShareableSet union with Self (75% overlap, distinct)", - "ShareableSet union with Self (100% overlap, distinct)", + "TreeSet union with Self (0% overlap, distinct)", + "TreeSet union with Self (25% overlap, distinct)", + "TreeSet union with Self (50% overlap, distinct)", + "TreeSet union with Self (75% overlap, distinct)", + "TreeSet union with Self (100% overlap, distinct)", ] }, { "kind": "chart", "title": "union with Self, shared", "tasks": [ - "ShareableSet union with Self (0% overlap, shared)", - "ShareableSet union with Self (25% overlap, shared)", - "ShareableSet union with Self (50% overlap, shared)", - "ShareableSet union with Self (75% overlap, shared)", - "ShareableSet union with Self (100% overlap, shared)", + "TreeSet union with Self (0% overlap, shared)", + "TreeSet union with Self (25% overlap, shared)", + "TreeSet union with Self (50% overlap, shared)", + "TreeSet union with Self (75% overlap, shared)", + "TreeSet union with Self (100% overlap, shared)", ] }, { "kind": "chart", "title": "union with Array", "tasks": [ - "ShareableSet union with Array (0% overlap)", - "ShareableSet union with Array (25% overlap)", - "ShareableSet union with Array (50% overlap)", - "ShareableSet union with Array (75% overlap)", - "ShareableSet union with Array (100% overlap)", + "TreeSet union with Array (0% overlap)", + "TreeSet union with Array (25% overlap)", + "TreeSet union with Array (50% overlap)", + "TreeSet union with Array (75% overlap)", + "TreeSet union with Array (100% overlap)", ] }, { "kind": "chart", "title": "formUnion with Self, distinct", "tasks": [ - "ShareableSet formUnion with Self (0% overlap, distinct)", - "ShareableSet formUnion with Self (25% overlap, distinct)", - "ShareableSet formUnion with Self (50% overlap, distinct)", - "ShareableSet formUnion with Self (75% overlap, distinct)", - "ShareableSet formUnion with Self (100% overlap, distinct)", + "TreeSet formUnion with Self (0% overlap, distinct)", + "TreeSet formUnion with Self (25% overlap, distinct)", + "TreeSet formUnion with Self (50% overlap, distinct)", + "TreeSet formUnion with Self (75% overlap, distinct)", + "TreeSet formUnion with Self (100% overlap, distinct)", ] }, { "kind": "chart", "title": "formUnion with Self, shared", "tasks": [ - "ShareableSet formUnion with Self (0% overlap, shared)", - "ShareableSet formUnion with Self (25% overlap, shared)", - "ShareableSet formUnion with Self (50% overlap, shared)", - "ShareableSet formUnion with Self (75% overlap, shared)", - "ShareableSet formUnion with Self (100% overlap, shared)", + "TreeSet formUnion with Self (0% overlap, shared)", + "TreeSet formUnion with Self (25% overlap, shared)", + "TreeSet formUnion with Self (50% overlap, shared)", + "TreeSet formUnion with Self (75% overlap, shared)", + "TreeSet formUnion with Self (100% overlap, shared)", ] }, { "kind": "chart", "title": "formUnion with Array", "tasks": [ - "ShareableSet formUnion with Array (0% overlap)", - "ShareableSet formUnion with Array (25% overlap)", - "ShareableSet formUnion with Array (50% overlap)", - "ShareableSet formUnion with Array (75% overlap)", - "ShareableSet formUnion with Array (100% overlap)", + "TreeSet formUnion with Array (0% overlap)", + "TreeSet formUnion with Array (25% overlap)", + "TreeSet formUnion with Array (50% overlap)", + "TreeSet formUnion with Array (75% overlap)", + "TreeSet formUnion with Array (100% overlap)", ] }, ] @@ -107,66 +107,66 @@ "kind": "chart", "title": "intersection with Self, distinct", "tasks": [ - "ShareableSet intersection with Self (0% overlap, distinct)", - "ShareableSet intersection with Self (25% overlap, distinct)", - "ShareableSet intersection with Self (50% overlap, distinct)", - "ShareableSet intersection with Self (75% overlap, distinct)", - "ShareableSet intersection with Self (100% overlap, distinct)", + "TreeSet intersection with Self (0% overlap, distinct)", + "TreeSet intersection with Self (25% overlap, distinct)", + "TreeSet intersection with Self (50% overlap, distinct)", + "TreeSet intersection with Self (75% overlap, distinct)", + "TreeSet intersection with Self (100% overlap, distinct)", ] }, { "kind": "chart", "title": "intersection with Self, shared", "tasks": [ - "ShareableSet intersection with Self (0% overlap, shared)", - "ShareableSet intersection with Self (25% overlap, shared)", - "ShareableSet intersection with Self (50% overlap, shared)", - "ShareableSet intersection with Self (75% overlap, shared)", - "ShareableSet intersection with Self (100% overlap, shared)", + "TreeSet intersection with Self (0% overlap, shared)", + "TreeSet intersection with Self (25% overlap, shared)", + "TreeSet intersection with Self (50% overlap, shared)", + "TreeSet intersection with Self (75% overlap, shared)", + "TreeSet intersection with Self (100% overlap, shared)", ] }, { "kind": "chart", "title": "intersection with Array", "tasks": [ - "ShareableSet intersection with Array (0% overlap)", - "ShareableSet intersection with Array (25% overlap)", - "ShareableSet intersection with Array (50% overlap)", - "ShareableSet intersection with Array (75% overlap)", - "ShareableSet intersection with Array (100% overlap)", + "TreeSet intersection with Array (0% overlap)", + "TreeSet intersection with Array (25% overlap)", + "TreeSet intersection with Array (50% overlap)", + "TreeSet intersection with Array (75% overlap)", + "TreeSet intersection with Array (100% overlap)", ] }, { "kind": "chart", "title": "formIntersection with Self, distinct", "tasks": [ - "ShareableSet formIntersection with Self (0% overlap, distinct)", - "ShareableSet formIntersection with Self (25% overlap, distinct)", - "ShareableSet formIntersection with Self (50% overlap, distinct)", - "ShareableSet formIntersection with Self (75% overlap, distinct)", - "ShareableSet formIntersection with Self (100% overlap, distinct)", + "TreeSet formIntersection with Self (0% overlap, distinct)", + "TreeSet formIntersection with Self (25% overlap, distinct)", + "TreeSet formIntersection with Self (50% overlap, distinct)", + "TreeSet formIntersection with Self (75% overlap, distinct)", + "TreeSet formIntersection with Self (100% overlap, distinct)", ] }, { "kind": "chart", "title": "formIntersection with Self, shared", "tasks": [ - "ShareableSet formIntersection with Self (0% overlap, shared)", - "ShareableSet formIntersection with Self (25% overlap, shared)", - "ShareableSet formIntersection with Self (50% overlap, shared)", - "ShareableSet formIntersection with Self (75% overlap, shared)", - "ShareableSet formIntersection with Self (100% overlap, shared)", + "TreeSet formIntersection with Self (0% overlap, shared)", + "TreeSet formIntersection with Self (25% overlap, shared)", + "TreeSet formIntersection with Self (50% overlap, shared)", + "TreeSet formIntersection with Self (75% overlap, shared)", + "TreeSet formIntersection with Self (100% overlap, shared)", ] }, { "kind": "chart", "title": "formIntersection with Array", "tasks": [ - "ShareableSet formIntersection with Array (0% overlap)", - "ShareableSet formIntersection with Array (25% overlap)", - "ShareableSet formIntersection with Array (50% overlap)", - "ShareableSet formIntersection with Array (75% overlap)", - "ShareableSet formIntersection with Array (100% overlap)", + "TreeSet formIntersection with Array (0% overlap)", + "TreeSet formIntersection with Array (25% overlap)", + "TreeSet formIntersection with Array (50% overlap)", + "TreeSet formIntersection with Array (75% overlap)", + "TreeSet formIntersection with Array (100% overlap)", ] }, ] @@ -178,66 +178,66 @@ "kind": "chart", "title": "symmetricDifference with Self, distinct", "tasks": [ - "ShareableSet symmetricDifference with Self (0% overlap, distinct)", - "ShareableSet symmetricDifference with Self (25% overlap, distinct)", - "ShareableSet symmetricDifference with Self (50% overlap, distinct)", - "ShareableSet symmetricDifference with Self (75% overlap, distinct)", - "ShareableSet symmetricDifference with Self (100% overlap, distinct)", + "TreeSet symmetricDifference with Self (0% overlap, distinct)", + "TreeSet symmetricDifference with Self (25% overlap, distinct)", + "TreeSet symmetricDifference with Self (50% overlap, distinct)", + "TreeSet symmetricDifference with Self (75% overlap, distinct)", + "TreeSet symmetricDifference with Self (100% overlap, distinct)", ] }, { "kind": "chart", "title": "symmetricDifference with Self, shared", "tasks": [ - "ShareableSet symmetricDifference with Self (0% overlap, shared)", - "ShareableSet symmetricDifference with Self (25% overlap, shared)", - "ShareableSet symmetricDifference with Self (50% overlap, shared)", - "ShareableSet symmetricDifference with Self (75% overlap, shared)", - "ShareableSet symmetricDifference with Self (100% overlap, shared)", + "TreeSet symmetricDifference with Self (0% overlap, shared)", + "TreeSet symmetricDifference with Self (25% overlap, shared)", + "TreeSet symmetricDifference with Self (50% overlap, shared)", + "TreeSet symmetricDifference with Self (75% overlap, shared)", + "TreeSet symmetricDifference with Self (100% overlap, shared)", ] }, { "kind": "chart", "title": "symmetricDifference with Array", "tasks": [ - "ShareableSet symmetricDifference with Array (0% overlap)", - "ShareableSet symmetricDifference with Array (25% overlap)", - "ShareableSet symmetricDifference with Array (50% overlap)", - "ShareableSet symmetricDifference with Array (75% overlap)", - "ShareableSet symmetricDifference with Array (100% overlap)", + "TreeSet symmetricDifference with Array (0% overlap)", + "TreeSet symmetricDifference with Array (25% overlap)", + "TreeSet symmetricDifference with Array (50% overlap)", + "TreeSet symmetricDifference with Array (75% overlap)", + "TreeSet symmetricDifference with Array (100% overlap)", ] }, { "kind": "chart", "title": "formSymmetricDifference with Self, distinct", "tasks": [ - "ShareableSet formSymmetricDifference with Self (0% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (25% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (50% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (75% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (100% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (0% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (25% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (50% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (75% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (100% overlap, distinct)", ] }, { "kind": "chart", "title": "formSymmetricDifference with Self, shared", "tasks": [ - "ShareableSet formSymmetricDifference with Self (0% overlap, shared)", - "ShareableSet formSymmetricDifference with Self (25% overlap, shared)", - "ShareableSet formSymmetricDifference with Self (50% overlap, shared)", - "ShareableSet formSymmetricDifference with Self (75% overlap, shared)", - "ShareableSet formSymmetricDifference with Self (100% overlap, shared)", + "TreeSet formSymmetricDifference with Self (0% overlap, shared)", + "TreeSet formSymmetricDifference with Self (25% overlap, shared)", + "TreeSet formSymmetricDifference with Self (50% overlap, shared)", + "TreeSet formSymmetricDifference with Self (75% overlap, shared)", + "TreeSet formSymmetricDifference with Self (100% overlap, shared)", ] }, { "kind": "chart", "title": "formSymmetricDifference with Array", "tasks": [ - "ShareableSet formSymmetricDifference with Array (0% overlap)", - "ShareableSet formSymmetricDifference with Array (25% overlap)", - "ShareableSet formSymmetricDifference with Array (50% overlap)", - "ShareableSet formSymmetricDifference with Array (75% overlap)", - "ShareableSet formSymmetricDifference with Array (100% overlap)", + "TreeSet formSymmetricDifference with Array (0% overlap)", + "TreeSet formSymmetricDifference with Array (25% overlap)", + "TreeSet formSymmetricDifference with Array (50% overlap)", + "TreeSet formSymmetricDifference with Array (75% overlap)", + "TreeSet formSymmetricDifference with Array (100% overlap)", ] }, ] @@ -249,66 +249,66 @@ "kind": "chart", "title": "subtracting Self, distinct", "tasks": [ - "ShareableSet subtracting Self (0% overlap, distinct)", - "ShareableSet subtracting Self (25% overlap, distinct)", - "ShareableSet subtracting Self (50% overlap, distinct)", - "ShareableSet subtracting Self (75% overlap, distinct)", - "ShareableSet subtracting Self (100% overlap, distinct)", + "TreeSet subtracting Self (0% overlap, distinct)", + "TreeSet subtracting Self (25% overlap, distinct)", + "TreeSet subtracting Self (50% overlap, distinct)", + "TreeSet subtracting Self (75% overlap, distinct)", + "TreeSet subtracting Self (100% overlap, distinct)", ] }, { "kind": "chart", "title": "subtracting Self, shared", "tasks": [ - "ShareableSet subtracting Self (0% overlap, shared)", - "ShareableSet subtracting Self (25% overlap, shared)", - "ShareableSet subtracting Self (50% overlap, shared)", - "ShareableSet subtracting Self (75% overlap, shared)", - "ShareableSet subtracting Self (100% overlap, shared)", + "TreeSet subtracting Self (0% overlap, shared)", + "TreeSet subtracting Self (25% overlap, shared)", + "TreeSet subtracting Self (50% overlap, shared)", + "TreeSet subtracting Self (75% overlap, shared)", + "TreeSet subtracting Self (100% overlap, shared)", ] }, { "kind": "chart", "title": "subtracting Array", "tasks": [ - "ShareableSet subtracting Array (0% overlap)", - "ShareableSet subtracting Array (25% overlap)", - "ShareableSet subtracting Array (50% overlap)", - "ShareableSet subtracting Array (75% overlap)", - "ShareableSet subtracting Array (100% overlap)", + "TreeSet subtracting Array (0% overlap)", + "TreeSet subtracting Array (25% overlap)", + "TreeSet subtracting Array (50% overlap)", + "TreeSet subtracting Array (75% overlap)", + "TreeSet subtracting Array (100% overlap)", ] }, { "kind": "chart", "title": "subtract Self, distinct", "tasks": [ - "ShareableSet subtract Self (0% overlap, distinct)", - "ShareableSet subtract Self (25% overlap, distinct)", - "ShareableSet subtract Self (50% overlap, distinct)", - "ShareableSet subtract Self (75% overlap, distinct)", - "ShareableSet subtract Self (100% overlap, distinct)", + "TreeSet subtract Self (0% overlap, distinct)", + "TreeSet subtract Self (25% overlap, distinct)", + "TreeSet subtract Self (50% overlap, distinct)", + "TreeSet subtract Self (75% overlap, distinct)", + "TreeSet subtract Self (100% overlap, distinct)", ] }, { "kind": "chart", "title": "subtract Self, shared", "tasks": [ - "ShareableSet subtract Self (0% overlap, shared)", - "ShareableSet subtract Self (25% overlap, shared)", - "ShareableSet subtract Self (50% overlap, shared)", - "ShareableSet subtract Self (75% overlap, shared)", - "ShareableSet subtract Self (100% overlap, shared)", + "TreeSet subtract Self (0% overlap, shared)", + "TreeSet subtract Self (25% overlap, shared)", + "TreeSet subtract Self (50% overlap, shared)", + "TreeSet subtract Self (75% overlap, shared)", + "TreeSet subtract Self (100% overlap, shared)", ] }, { "kind": "chart", "title": "subtract with Array", "tasks": [ - "ShareableSet subtract Array (0% overlap)", - "ShareableSet subtract Array (25% overlap)", - "ShareableSet subtract Array (50% overlap)", - "ShareableSet subtract Array (75% overlap)", - "ShareableSet subtract Array (100% overlap)", + "TreeSet subtract Array (0% overlap)", + "TreeSet subtract Array (25% overlap)", + "TreeSet subtract Array (50% overlap)", + "TreeSet subtract Array (75% overlap)", + "TreeSet subtract Array (100% overlap)", ] }, ] @@ -324,7 +324,7 @@ "kind": "chart", "title": "init from buffer of integers", "tasks": [ - "ShareableSet init from unsafe buffer", + "TreeSet init from unsafe buffer", "Set init from unsafe buffer", ] }, @@ -332,7 +332,7 @@ "kind": "chart", "title": "init from range of integers", "tasks": [ - "ShareableSet init from range", + "TreeSet init from range", "Set init from range", ] }, @@ -340,7 +340,7 @@ "kind": "chart", "title": "sequential iteration", "tasks": [ - "ShareableSet sequential iteration", + "TreeSet sequential iteration", "Set sequential iteration", ] }, @@ -348,7 +348,7 @@ "kind": "chart", "title": "sequential iteration using indices", "tasks": [ - "ShareableSet sequential iteration, indices", + "TreeSet sequential iteration, indices", "Set sequential iteration, indices", ] }, @@ -356,7 +356,7 @@ "kind": "chart", "title": "successful random lookups", "tasks": [ - "ShareableSet successful contains", + "TreeSet successful contains", "Set successful contains", ] }, @@ -364,7 +364,7 @@ "kind": "chart", "title": "unsuccessful random lookups", "tasks": [ - "ShareableSet unsuccessful contains", + "TreeSet unsuccessful contains", "Set unsuccessful contains", ] }, @@ -372,7 +372,7 @@ "kind": "chart", "title": "insert", "tasks": [ - "ShareableSet insert", + "TreeSet insert", "Set insert", "Set insert, reserving capacity", ] @@ -381,7 +381,7 @@ "kind": "chart", "title": "insert-shared", "tasks": [ - "ShareableSet insert, shared", + "TreeSet insert, shared", "Set insert, shared", ] }, @@ -389,7 +389,7 @@ "kind": "chart", "title": "model building with constant diffing", "tasks": [ - "ShareableSet model diffing", + "TreeSet model diffing", "Set model diffing" ] }, @@ -397,8 +397,8 @@ "kind": "chart", "title": "remove", "tasks": [ - "ShareableSet remove", - "ShareableSet remove, shared", + "TreeSet remove", + "TreeSet remove, shared", "Set remove", "Set remove, shared", ] @@ -410,9 +410,9 @@ "kind": "chart", "title": "union (0% overlap)", "tasks": [ - "ShareableSet union with Self (0% overlap, distinct)", - "ShareableSet union with Self (0% overlap, shared)", - "ShareableSet union with Array (0% overlap)", + "TreeSet union with Self (0% overlap, distinct)", + "TreeSet union with Self (0% overlap, shared)", + "TreeSet union with Array (0% overlap)", "Set union with Self (0% overlap)", "Set union with Array (0% overlap)", ] @@ -421,9 +421,9 @@ "kind": "chart", "title": "union (25% overlap)", "tasks": [ - "ShareableSet union with Self (25% overlap, distinct)", - "ShareableSet union with Self (25% overlap, shared)", - "ShareableSet union with Array (25% overlap)", + "TreeSet union with Self (25% overlap, distinct)", + "TreeSet union with Self (25% overlap, shared)", + "TreeSet union with Array (25% overlap)", "Set union with Self (25% overlap)", "Set union with Array (25% overlap)", ] @@ -432,9 +432,9 @@ "kind": "chart", "title": "union (50% overlap)", "tasks": [ - "ShareableSet union with Self (50% overlap, distinct)", - "ShareableSet union with Self (50% overlap, shared)", - "ShareableSet union with Array (50% overlap)", + "TreeSet union with Self (50% overlap, distinct)", + "TreeSet union with Self (50% overlap, shared)", + "TreeSet union with Array (50% overlap)", "Set union with Self (50% overlap)", "Set union with Array (50% overlap)", ] @@ -443,9 +443,9 @@ "kind": "chart", "title": "union (75% overlap)", "tasks": [ - "ShareableSet union with Self (75% overlap, distinct)", - "ShareableSet union with Self (75% overlap, shared)", - "ShareableSet union with Array (75% overlap)", + "TreeSet union with Self (75% overlap, distinct)", + "TreeSet union with Self (75% overlap, shared)", + "TreeSet union with Array (75% overlap)", "Set union with Self (75% overlap)", "Set union with Array (75% overlap)", ] @@ -454,9 +454,9 @@ "kind": "chart", "title": "union (100% overlap)", "tasks": [ - "ShareableSet union with Self (100% overlap, distinct)", - "ShareableSet union with Self (100% overlap, shared)", - "ShareableSet union with Array (100% overlap)", + "TreeSet union with Self (100% overlap, distinct)", + "TreeSet union with Self (100% overlap, shared)", + "TreeSet union with Array (100% overlap)", "Set union with Self (100% overlap)", "Set union with Array (100% overlap)", ] @@ -470,9 +470,9 @@ "kind": "chart", "title": "formUnion (0% overlap)", "tasks": [ - "ShareableSet formUnion with Self (0% overlap, distinct)", - "ShareableSet formUnion with Self (0% overlap, shared)", - "ShareableSet formUnion with Array (0% overlap)", + "TreeSet formUnion with Self (0% overlap, distinct)", + "TreeSet formUnion with Self (0% overlap, shared)", + "TreeSet formUnion with Array (0% overlap)", "Set formUnion with Self (0% overlap)", "Set formUnion with Array (0% overlap)", ] @@ -481,9 +481,9 @@ "kind": "chart", "title": "formUnion (25% overlap)", "tasks": [ - "ShareableSet formUnion with Self (25% overlap, distinct)", - "ShareableSet formUnion with Self (25% overlap, shared)", - "ShareableSet formUnion with Array (25% overlap)", + "TreeSet formUnion with Self (25% overlap, distinct)", + "TreeSet formUnion with Self (25% overlap, shared)", + "TreeSet formUnion with Array (25% overlap)", "Set formUnion with Self (25% overlap)", "Set formUnion with Array (25% overlap)", ] @@ -492,9 +492,9 @@ "kind": "chart", "title": "formUnion (50% overlap)", "tasks": [ - "ShareableSet formUnion with Self (50% overlap, distinct)", - "ShareableSet formUnion with Self (50% overlap, shared)", - "ShareableSet formUnion with Array (50% overlap)", + "TreeSet formUnion with Self (50% overlap, distinct)", + "TreeSet formUnion with Self (50% overlap, shared)", + "TreeSet formUnion with Array (50% overlap)", "Set formUnion with Self (50% overlap)", "Set formUnion with Array (50% overlap)", ] @@ -503,9 +503,9 @@ "kind": "chart", "title": "formUnion (75% overlap)", "tasks": [ - "ShareableSet formUnion with Self (75% overlap, distinct)", - "ShareableSet formUnion with Self (75% overlap, shared)", - "ShareableSet formUnion with Array (75% overlap)", + "TreeSet formUnion with Self (75% overlap, distinct)", + "TreeSet formUnion with Self (75% overlap, shared)", + "TreeSet formUnion with Array (75% overlap)", "Set formUnion with Self (75% overlap)", "Set formUnion with Array (75% overlap)", ] @@ -514,9 +514,9 @@ "kind": "chart", "title": "formUnion (100% overlap)", "tasks": [ - "ShareableSet formUnion with Self (100% overlap, distinct)", - "ShareableSet formUnion with Self (100% overlap, shared)", - "ShareableSet formUnion with Array (100% overlap)", + "TreeSet formUnion with Self (100% overlap, distinct)", + "TreeSet formUnion with Self (100% overlap, shared)", + "TreeSet formUnion with Array (100% overlap)", "Set formUnion with Self (100% overlap)", "Set formUnion with Array (100% overlap)", ] @@ -530,9 +530,9 @@ "kind": "chart", "title": "intersection (0% overlap)", "tasks": [ - "ShareableSet intersection with Self (0% overlap, distinct)", - "ShareableSet intersection with Self (0% overlap, shared)", - "ShareableSet intersection with Array (0% overlap)", + "TreeSet intersection with Self (0% overlap, distinct)", + "TreeSet intersection with Self (0% overlap, shared)", + "TreeSet intersection with Array (0% overlap)", "Set intersection with Self (0% overlap)", "Set intersection with Array (0% overlap)", ] @@ -541,9 +541,9 @@ "kind": "chart", "title": "intersection (25% overlap)", "tasks": [ - "ShareableSet intersection with Self (25% overlap, distinct)", - "ShareableSet intersection with Self (25% overlap, shared)", - "ShareableSet intersection with Array (25% overlap)", + "TreeSet intersection with Self (25% overlap, distinct)", + "TreeSet intersection with Self (25% overlap, shared)", + "TreeSet intersection with Array (25% overlap)", "Set intersection with Self (25% overlap)", "Set intersection with Array (25% overlap)", ] @@ -552,9 +552,9 @@ "kind": "chart", "title": "intersection (50% overlap)", "tasks": [ - "ShareableSet intersection with Self (50% overlap, distinct)", - "ShareableSet intersection with Self (50% overlap, shared)", - "ShareableSet intersection with Array (50% overlap)", + "TreeSet intersection with Self (50% overlap, distinct)", + "TreeSet intersection with Self (50% overlap, shared)", + "TreeSet intersection with Array (50% overlap)", "Set intersection with Self (50% overlap)", "Set intersection with Array (50% overlap)", ] @@ -563,9 +563,9 @@ "kind": "chart", "title": "intersection (75% overlap)", "tasks": [ - "ShareableSet intersection with Self (75% overlap, distinct)", - "ShareableSet intersection with Self (75% overlap, shared)", - "ShareableSet intersection with Array (75% overlap)", + "TreeSet intersection with Self (75% overlap, distinct)", + "TreeSet intersection with Self (75% overlap, shared)", + "TreeSet intersection with Array (75% overlap)", "Set intersection with Self (75% overlap)", "Set intersection with Array (75% overlap)", ] @@ -574,9 +574,9 @@ "kind": "chart", "title": "intersection (100% overlap)", "tasks": [ - "ShareableSet intersection with Self (100% overlap, distinct)", - "ShareableSet intersection with Self (100% overlap, shared)", - "ShareableSet intersection with Array (100% overlap)", + "TreeSet intersection with Self (100% overlap, distinct)", + "TreeSet intersection with Self (100% overlap, shared)", + "TreeSet intersection with Array (100% overlap)", "Set intersection with Self (100% overlap)", "Set intersection with Array (100% overlap)", ] @@ -590,9 +590,9 @@ "kind": "chart", "title": "formIntersection (0% overlap)", "tasks": [ - "ShareableSet formIntersection with Self (0% overlap, distinct)", - "ShareableSet formIntersection with Self (0% overlap, shared)", - "ShareableSet formIntersection with Array (0% overlap)", + "TreeSet formIntersection with Self (0% overlap, distinct)", + "TreeSet formIntersection with Self (0% overlap, shared)", + "TreeSet formIntersection with Array (0% overlap)", "Set formIntersection with Self (0% overlap)", "Set formIntersection with Array (0% overlap)", ] @@ -601,9 +601,9 @@ "kind": "chart", "title": "formIntersection (25% overlap)", "tasks": [ - "ShareableSet formIntersection with Self (25% overlap, distinct)", - "ShareableSet formIntersection with Self (25% overlap, shared)", - "ShareableSet formIntersection with Array (25% overlap)", + "TreeSet formIntersection with Self (25% overlap, distinct)", + "TreeSet formIntersection with Self (25% overlap, shared)", + "TreeSet formIntersection with Array (25% overlap)", "Set formIntersection with Self (25% overlap)", "Set formIntersection with Array (25% overlap)", ] @@ -612,9 +612,9 @@ "kind": "chart", "title": "formIntersection (50% overlap)", "tasks": [ - "ShareableSet formIntersection with Self (50% overlap, distinct)", - "ShareableSet formIntersection with Self (50% overlap, shared)", - "ShareableSet formIntersection with Array (50% overlap)", + "TreeSet formIntersection with Self (50% overlap, distinct)", + "TreeSet formIntersection with Self (50% overlap, shared)", + "TreeSet formIntersection with Array (50% overlap)", "Set formIntersection with Self (50% overlap)", "Set formIntersection with Array (50% overlap)", ] @@ -623,9 +623,9 @@ "kind": "chart", "title": "formIntersection (75% overlap)", "tasks": [ - "ShareableSet formIntersection with Self (75% overlap, distinct)", - "ShareableSet formIntersection with Self (75% overlap, shared)", - "ShareableSet formIntersection with Array (75% overlap)", + "TreeSet formIntersection with Self (75% overlap, distinct)", + "TreeSet formIntersection with Self (75% overlap, shared)", + "TreeSet formIntersection with Array (75% overlap)", "Set formIntersection with Self (75% overlap)", "Set formIntersection with Array (75% overlap)", ] @@ -634,9 +634,9 @@ "kind": "chart", "title": "formIntersection (100% overlap)", "tasks": [ - "ShareableSet formIntersection with Self (100% overlap, distinct)", - "ShareableSet formIntersection with Self (100% overlap, shared)", - "ShareableSet formIntersection with Array (100% overlap)", + "TreeSet formIntersection with Self (100% overlap, distinct)", + "TreeSet formIntersection with Self (100% overlap, shared)", + "TreeSet formIntersection with Array (100% overlap)", "Set formIntersection with Self (100% overlap)", "Set formIntersection with Array (100% overlap)", ] @@ -650,9 +650,9 @@ "kind": "chart", "title": "symmetricDifference (0% overlap)", "tasks": [ - "ShareableSet symmetricDifference with Self (0% overlap, distinct)", - "ShareableSet symmetricDifference with Self (0% overlap, shared)", - "ShareableSet symmetricDifference with Array (0% overlap)", + "TreeSet symmetricDifference with Self (0% overlap, distinct)", + "TreeSet symmetricDifference with Self (0% overlap, shared)", + "TreeSet symmetricDifference with Array (0% overlap)", "Set symmetricDifference with Self (0% overlap)", "Set symmetricDifference with Array (0% overlap)", ] @@ -661,9 +661,9 @@ "kind": "chart", "title": "symmetricDifference (25% overlap)", "tasks": [ - "ShareableSet symmetricDifference with Self (25% overlap, distinct)", - "ShareableSet symmetricDifference with Self (25% overlap, shared)", - "ShareableSet symmetricDifference with Array (25% overlap)", + "TreeSet symmetricDifference with Self (25% overlap, distinct)", + "TreeSet symmetricDifference with Self (25% overlap, shared)", + "TreeSet symmetricDifference with Array (25% overlap)", "Set symmetricDifference with Self (25% overlap)", "Set symmetricDifference with Array (25% overlap)", ] @@ -672,9 +672,9 @@ "kind": "chart", "title": "symmetricDifference (50% overlap)", "tasks": [ - "ShareableSet symmetricDifference with Self (50% overlap, distinct)", - "ShareableSet symmetricDifference with Self (50% overlap, shared)", - "ShareableSet symmetricDifference with Array (50% overlap)", + "TreeSet symmetricDifference with Self (50% overlap, distinct)", + "TreeSet symmetricDifference with Self (50% overlap, shared)", + "TreeSet symmetricDifference with Array (50% overlap)", "Set symmetricDifference with Self (50% overlap)", "Set symmetricDifference with Array (50% overlap)", ] @@ -683,9 +683,9 @@ "kind": "chart", "title": "symmetricDifference (75% overlap)", "tasks": [ - "ShareableSet symmetricDifference with Self (75% overlap, distinct)", - "ShareableSet symmetricDifference with Self (75% overlap, shared)", - "ShareableSet symmetricDifference with Array (75% overlap)", + "TreeSet symmetricDifference with Self (75% overlap, distinct)", + "TreeSet symmetricDifference with Self (75% overlap, shared)", + "TreeSet symmetricDifference with Array (75% overlap)", "Set symmetricDifference with Self (75% overlap)", "Set symmetricDifference with Array (75% overlap)", ] @@ -694,9 +694,9 @@ "kind": "chart", "title": "symmetricDifference (100% overlap)", "tasks": [ - "ShareableSet symmetricDifference with Self (100% overlap, distinct)", - "ShareableSet symmetricDifference with Self (100% overlap, shared)", - "ShareableSet symmetricDifference with Array (100% overlap)", + "TreeSet symmetricDifference with Self (100% overlap, distinct)", + "TreeSet symmetricDifference with Self (100% overlap, shared)", + "TreeSet symmetricDifference with Array (100% overlap)", "Set symmetricDifference with Self (100% overlap)", "Set symmetricDifference with Array (100% overlap)", ] @@ -710,9 +710,9 @@ "kind": "chart", "title": "formSymmetricDifference (0% overlap)", "tasks": [ - "ShareableSet formSymmetricDifference with Self (0% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (0% overlap, shared)", - "ShareableSet formSymmetricDifference with Array (0% overlap)", + "TreeSet formSymmetricDifference with Self (0% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (0% overlap, shared)", + "TreeSet formSymmetricDifference with Array (0% overlap)", "Set formSymmetricDifference with Self (0% overlap)", "Set formSymmetricDifference with Array (0% overlap)", ] @@ -721,9 +721,9 @@ "kind": "chart", "title": "formSymmetricDifference (25% overlap)", "tasks": [ - "ShareableSet formSymmetricDifference with Self (25% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (25% overlap, shared)", - "ShareableSet formSymmetricDifference with Array (25% overlap)", + "TreeSet formSymmetricDifference with Self (25% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (25% overlap, shared)", + "TreeSet formSymmetricDifference with Array (25% overlap)", "Set formSymmetricDifference with Self (25% overlap)", "Set formSymmetricDifference with Array (25% overlap)", ] @@ -732,9 +732,9 @@ "kind": "chart", "title": "formSymmetricDifference (50% overlap)", "tasks": [ - "ShareableSet formSymmetricDifference with Self (50% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (50% overlap, shared)", - "ShareableSet formSymmetricDifference with Array (50% overlap)", + "TreeSet formSymmetricDifference with Self (50% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (50% overlap, shared)", + "TreeSet formSymmetricDifference with Array (50% overlap)", "Set formSymmetricDifference with Self (50% overlap)", "Set formSymmetricDifference with Array (50% overlap)", ] @@ -743,9 +743,9 @@ "kind": "chart", "title": "formSymmetricDifference (75% overlap)", "tasks": [ - "ShareableSet formSymmetricDifference with Self (75% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (75% overlap, shared)", - "ShareableSet formSymmetricDifference with Array (75% overlap)", + "TreeSet formSymmetricDifference with Self (75% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (75% overlap, shared)", + "TreeSet formSymmetricDifference with Array (75% overlap)", "Set formSymmetricDifference with Self (75% overlap)", "Set formSymmetricDifference with Array (75% overlap)", ] @@ -754,9 +754,9 @@ "kind": "chart", "title": "formSymmetricDifference (100% overlap)", "tasks": [ - "ShareableSet formSymmetricDifference with Self (100% overlap, distinct)", - "ShareableSet formSymmetricDifference with Self (100% overlap, shared)", - "ShareableSet formSymmetricDifference with Array (100% overlap)", + "TreeSet formSymmetricDifference with Self (100% overlap, distinct)", + "TreeSet formSymmetricDifference with Self (100% overlap, shared)", + "TreeSet formSymmetricDifference with Array (100% overlap)", "Set formSymmetricDifference with Self (100% overlap)", "Set formSymmetricDifference with Array (100% overlap)", ] @@ -770,9 +770,9 @@ "kind": "chart", "title": "subtracting (0% overlap)", "tasks": [ - "ShareableSet subtracting Self (0% overlap, distinct)", - "ShareableSet subtracting Self (0% overlap, shared)", - "ShareableSet subtracting Array (0% overlap)", + "TreeSet subtracting Self (0% overlap, distinct)", + "TreeSet subtracting Self (0% overlap, shared)", + "TreeSet subtracting Array (0% overlap)", "Set subtracting Self (0% overlap)", "Set subtracting Array (0% overlap)", ] @@ -781,9 +781,9 @@ "kind": "chart", "title": "subtracting (25% overlap)", "tasks": [ - "ShareableSet subtracting Self (25% overlap, distinct)", - "ShareableSet subtracting Self (25% overlap, shared)", - "ShareableSet subtracting Array (25% overlap)", + "TreeSet subtracting Self (25% overlap, distinct)", + "TreeSet subtracting Self (25% overlap, shared)", + "TreeSet subtracting Array (25% overlap)", "Set subtracting Self (25% overlap)", "Set subtracting Array (25% overlap)", ] @@ -792,9 +792,9 @@ "kind": "chart", "title": "subtracting (50% overlap)", "tasks": [ - "ShareableSet subtracting Self (50% overlap, distinct)", - "ShareableSet subtracting Self (50% overlap, shared)", - "ShareableSet subtracting Array (50% overlap)", + "TreeSet subtracting Self (50% overlap, distinct)", + "TreeSet subtracting Self (50% overlap, shared)", + "TreeSet subtracting Array (50% overlap)", "Set subtracting Self (50% overlap)", "Set subtracting Array (50% overlap)", ] @@ -803,9 +803,9 @@ "kind": "chart", "title": "subtracting (75% overlap)", "tasks": [ - "ShareableSet subtracting Self (75% overlap, distinct)", - "ShareableSet subtracting Self (75% overlap, shared)", - "ShareableSet subtracting Array (75% overlap)", + "TreeSet subtracting Self (75% overlap, distinct)", + "TreeSet subtracting Self (75% overlap, shared)", + "TreeSet subtracting Array (75% overlap)", "Set subtracting Self (75% overlap)", "Set subtracting Array (75% overlap)", ] @@ -814,9 +814,9 @@ "kind": "chart", "title": "subtracting (100% overlap)", "tasks": [ - "ShareableSet subtracting Self (100% overlap, distinct)", - "ShareableSet subtracting Self (100% overlap, shared)", - "ShareableSet subtracting Array (100% overlap)", + "TreeSet subtracting Self (100% overlap, distinct)", + "TreeSet subtracting Self (100% overlap, shared)", + "TreeSet subtracting Array (100% overlap)", "Set subtracting Self (100% overlap)", "Set subtracting Array (100% overlap)", ] @@ -830,9 +830,9 @@ "kind": "chart", "title": "subtract (0% overlap)", "tasks": [ - "ShareableSet subtract Self (0% overlap, distinct)", - "ShareableSet subtract Self (0% overlap, shared)", - "ShareableSet subtract Array (0% overlap)", + "TreeSet subtract Self (0% overlap, distinct)", + "TreeSet subtract Self (0% overlap, shared)", + "TreeSet subtract Array (0% overlap)", "Set subtract Self (0% overlap)", "Set subtract Array (0% overlap)", ] @@ -841,9 +841,9 @@ "kind": "chart", "title": "subtract (25% overlap)", "tasks": [ - "ShareableSet subtract Self (25% overlap, distinct)", - "ShareableSet subtract Self (25% overlap, shared)", - "ShareableSet subtract Array (25% overlap)", + "TreeSet subtract Self (25% overlap, distinct)", + "TreeSet subtract Self (25% overlap, shared)", + "TreeSet subtract Array (25% overlap)", "Set subtract Self (25% overlap)", "Set subtract Array (25% overlap)", ] @@ -852,9 +852,9 @@ "kind": "chart", "title": "subtract (50% overlap)", "tasks": [ - "ShareableSet subtract Self (50% overlap, distinct)", - "ShareableSet subtract Self (50% overlap, shared)", - "ShareableSet subtract Array (50% overlap)", + "TreeSet subtract Self (50% overlap, distinct)", + "TreeSet subtract Self (50% overlap, shared)", + "TreeSet subtract Array (50% overlap)", "Set subtract Self (50% overlap)", "Set subtract Array (50% overlap)", ] @@ -863,9 +863,9 @@ "kind": "chart", "title": "subtract (75% overlap)", "tasks": [ - "ShareableSet subtract Self (75% overlap, distinct)", - "ShareableSet subtract Self (75% overlap, shared)", - "ShareableSet subtract Array (75% overlap)", + "TreeSet subtract Self (75% overlap, distinct)", + "TreeSet subtract Self (75% overlap, shared)", + "TreeSet subtract Array (75% overlap)", "Set subtract Self (75% overlap)", "Set subtract Array (75% overlap)", ] @@ -874,9 +874,9 @@ "kind": "chart", "title": "subtract (100% overlap)", "tasks": [ - "ShareableSet subtract Self (100% overlap, distinct)", - "ShareableSet subtract Self (100% overlap, shared)", - "ShareableSet subtract Array (100% overlap)", + "TreeSet subtract Self (100% overlap, distinct)", + "TreeSet subtract Self (100% overlap, shared)", + "TreeSet subtract Array (100% overlap)", "Set subtract Self (100% overlap)", "Set subtract Array (100% overlap)", ] diff --git a/Benchmarks/Sources/Benchmarks/ShareableDictionaryBenchmarks.swift b/Benchmarks/Sources/Benchmarks/ShareableDictionaryBenchmarks.swift index 288b13d2..677bff27 100644 --- a/Benchmarks/Sources/Benchmarks/ShareableDictionaryBenchmarks.swift +++ b/Benchmarks/Sources/Benchmarks/ShareableDictionaryBenchmarks.swift @@ -10,25 +10,25 @@ //===----------------------------------------------------------------------===// import CollectionsBenchmark -import ShareableHashedCollections +import HashTreeCollections extension Benchmark { - public mutating func addShareableDictionaryBenchmarks() { + public mutating func addTreeDictionaryBenchmarks() { self.add( - title: "ShareableDictionary init(uniqueKeysWithValues:)", + title: "TreeDictionary init(uniqueKeysWithValues:)", input: [Int].self ) { input in let keysAndValues = input.map { ($0, 2 * $0) } return { timer in - blackHole(ShareableDictionary(uniqueKeysWithValues: keysAndValues)) + blackHole(TreeDictionary(uniqueKeysWithValues: keysAndValues)) } } self.add( - title: "ShareableDictionary sequential iteration", + title: "TreeDictionary sequential iteration", input: [Int].self ) { input in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in for item in d { blackHole(item) @@ -37,10 +37,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary.Keys sequential iteration", + title: "TreeDictionary.Keys sequential iteration", input: [Int].self ) { input in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in for item in d.keys { blackHole(item) @@ -49,10 +49,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary.Values sequential iteration", + title: "TreeDictionary.Values sequential iteration", input: [Int].self ) { input in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in for item in d.values { blackHole(item) @@ -61,10 +61,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary sequential iteration, indices", + title: "TreeDictionary sequential iteration, indices", input: [Int].self ) { input in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in for i in d.indices { blackHole(d[i]) @@ -73,10 +73,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary striding, 10 steps", + title: "TreeDictionary striding, 10 steps", input: [Int].self ) { input in - let d = ShareableDictionary( + let d = TreeDictionary( uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) let steps = stride(from: 0, through: 10 * d.count, by: d.count) .map { $0 / 10 } @@ -92,10 +92,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary indexing subscript", + title: "TreeDictionary indexing subscript", input: ([Int], [Int]).self ) { input, lookups in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) let indices = lookups.map { d.index(forKey: $0)! } return { timer in for i in indices { @@ -105,10 +105,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, successful lookups", + title: "TreeDictionary subscript, successful lookups", input: ([Int], [Int]).self ) { input, lookups in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in for i in lookups { precondition(d[i] == 2 * i) @@ -117,10 +117,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, unsuccessful lookups", + title: "TreeDictionary subscript, unsuccessful lookups", input: ([Int], [Int]).self ) { input, lookups in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) let c = input.count return { timer in for i in lookups { @@ -130,11 +130,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, noop setter", + title: "TreeDictionary subscript, noop setter", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) let c = input.count timer.measure { for i in lookups { @@ -147,11 +147,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, set existing", + title: "TreeDictionary subscript, set existing", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) timer.measure { for i in lookups { d[i] = 0 @@ -163,11 +163,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, _modify", + title: "TreeDictionary subscript, _modify", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) timer.measure { for i in lookups { d[i]! *= 2 @@ -179,10 +179,10 @@ extension Benchmark { } self.addSimple( - title: "ShareableDictionary subscript, insert, unique", + title: "TreeDictionary subscript, insert, unique", input: [Int].self ) { input in - var d: ShareableDictionary = [:] + var d: TreeDictionary = [:] for i in input { d[i] = 2 * i } @@ -191,10 +191,10 @@ extension Benchmark { } self.addSimple( - title: "ShareableDictionary subscript, insert, shared", + title: "TreeDictionary subscript, insert, shared", input: [Int].self ) { input in - var d: ShareableDictionary = [:] + var d: TreeDictionary = [:] for i in input { let copy = d d[i] = 2 * i @@ -205,11 +205,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, remove existing, unique", + title: "TreeDictionary subscript, remove existing, unique", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) timer.measure { for i in lookups { d[i] = nil @@ -221,11 +221,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, remove existing, shared", + title: "TreeDictionary subscript, remove existing, shared", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) timer.measure { for i in lookups { let copy = d @@ -239,11 +239,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, remove missing", + title: "TreeDictionary subscript, remove missing", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) let c = input.count timer.measure { for i in lookups { @@ -256,10 +256,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary defaulted subscript, successful lookups", + title: "TreeDictionary defaulted subscript, successful lookups", input: ([Int], [Int]).self ) { input, lookups in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in for i in lookups { precondition(d[i, default: -1] != -1) @@ -268,10 +268,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary defaulted subscript, unsuccessful lookups", + title: "TreeDictionary defaulted subscript, unsuccessful lookups", input: ([Int], [Int]).self ) { input, lookups in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in let c = d.count for i in lookups { @@ -281,11 +281,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary defaulted subscript, _modify existing", + title: "TreeDictionary defaulted subscript, _modify existing", input: [Int].self ) { input in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) timer.measure { for i in input { d[i, default: -1] *= 2 @@ -297,11 +297,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary defaulted subscript, _modify missing", + title: "TreeDictionary defaulted subscript, _modify missing", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) let c = input.count timer.measure { for i in lookups { @@ -314,10 +314,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary successful index(forKey:)", + title: "TreeDictionary successful index(forKey:)", input: ([Int], [Int]).self ) { input, lookups in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in for i in lookups { precondition(d.index(forKey: i) != nil) @@ -326,10 +326,10 @@ extension Benchmark { } self.add( - title: "ShareableDictionary unsuccessful index(forKey:)", + title: "TreeDictionary unsuccessful index(forKey:)", input: ([Int], [Int]).self ) { input, lookups in - let d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + let d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) return { timer in for i in lookups { precondition(d.index(forKey: lookups.count + i) == nil) @@ -338,11 +338,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary updateValue(_:forKey:), existing", + title: "TreeDictionary updateValue(_:forKey:), existing", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) timer.measure { for i in lookups { d.updateValue(0, forKey: i) @@ -354,11 +354,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary updateValue(_:forKey:), insert", + title: "TreeDictionary updateValue(_:forKey:), insert", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) timer.measure { for i in lookups { d.updateValue(0, forKey: input.count + i) @@ -370,11 +370,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary random removals (existing keys)", + title: "TreeDictionary random removals (existing keys)", input: ([Int], [Int]).self ) { input, lookups in return { timer in - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) timer.measure { for i in lookups { precondition(d.removeValue(forKey: i) != nil) @@ -386,12 +386,12 @@ extension Benchmark { } self.add( - title: "ShareableDictionary random removals (missing keys)", + title: "TreeDictionary random removals (missing keys)", input: ([Int], [Int]).self ) { input, lookups in return { timer in let c = input.count - var d = ShareableDictionary(uniqueKeysWithValues: input.lazy.map { (c + $0, 2 * $0) }) + var d = TreeDictionary(uniqueKeysWithValues: input.lazy.map { (c + $0, 2 * $0) }) timer.measure { for i in lookups { precondition(d.removeValue(forKey: i) == nil) @@ -403,11 +403,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, insert, unique", + title: "TreeDictionary subscript, insert, unique", input: [Large].self ) { input in return { timer in - var d: ShareableDictionary = [:] + var d: TreeDictionary = [:] timer.measure { for value in input { d[value] = value @@ -419,11 +419,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, insert, shared", + title: "TreeDictionary subscript, insert, shared", input: [Large].self ) { input in return { timer in - var d: ShareableDictionary = [:] + var d: TreeDictionary = [:] timer.measure { for value in input { let copy = d @@ -437,11 +437,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, remove existing, unique", + title: "TreeDictionary subscript, remove existing, unique", input: ([Large], [Large]).self ) { input, lookups in return { timer in - var d = ShareableDictionary( + var d = TreeDictionary( uniqueKeysWithValues: input.lazy.map { ($0, $0) }) timer.measure { for key in lookups { @@ -454,11 +454,11 @@ extension Benchmark { } self.add( - title: "ShareableDictionary subscript, remove existing, shared", + title: "TreeDictionary subscript, remove existing, shared", input: ([Large], [Large]).self ) { input, lookups in return { timer in - var d = ShareableDictionary( + var d = TreeDictionary( uniqueKeysWithValues: input.lazy.map { ($0, $0) }) timer.measure { for key in lookups { diff --git a/Benchmarks/Sources/Benchmarks/ShareableSetBenchmarks.swift b/Benchmarks/Sources/Benchmarks/ShareableSetBenchmarks.swift index 73aceb72..5cf0cb14 100644 --- a/Benchmarks/Sources/Benchmarks/ShareableSetBenchmarks.swift +++ b/Benchmarks/Sources/Benchmarks/ShareableSetBenchmarks.swift @@ -10,31 +10,31 @@ //===----------------------------------------------------------------------===// import CollectionsBenchmark -import ShareableHashedCollections +import HashTreeCollections extension Benchmark { - public mutating func addShareableSetBenchmarks() { + public mutating func addTreeSetBenchmarks() { self.addSimple( - title: "ShareableSet init from range", + title: "TreeSet init from range", input: Int.self ) { size in - blackHole(ShareableSet(0 ..< size)) + blackHole(TreeSet(0 ..< size)) } self.addSimple( - title: "ShareableSet init from unsafe buffer", + title: "TreeSet init from unsafe buffer", input: [Int].self ) { input in input.withUnsafeBufferPointer { buffer in - blackHole(ShareableSet(buffer)) + blackHole(TreeSet(buffer)) } } self.add( - title: "ShareableSet sequential iteration", + title: "TreeSet sequential iteration", input: Int.self ) { size in - let set = ShareableSet(0 ..< size) + let set = TreeSet(0 ..< size) return { timer in for i in set { blackHole(i) @@ -43,10 +43,10 @@ extension Benchmark { } self.add( - title: "ShareableSet sequential iteration, indices", + title: "TreeSet sequential iteration, indices", input: Int.self ) { size in - let set = ShareableSet(0 ..< size) + let set = TreeSet(0 ..< size) return { timer in for i in set.indices { blackHole(set[i]) @@ -55,10 +55,10 @@ extension Benchmark { } self.add( - title: "ShareableSet successful contains", + title: "TreeSet successful contains", input: ([Int], [Int]).self ) { input, lookups in - let set = ShareableSet(input) + let set = TreeSet(input) return { timer in for i in lookups { precondition(set.contains(i)) @@ -67,10 +67,10 @@ extension Benchmark { } self.add( - title: "ShareableSet unsuccessful contains", + title: "TreeSet unsuccessful contains", input: ([Int], [Int]).self ) { input, lookups in - let set = ShareableSet(input) + let set = TreeSet(input) let lookups = lookups.map { $0 + input.count } return { timer in for i in lookups { @@ -80,10 +80,10 @@ extension Benchmark { } self.addSimple( - title: "ShareableSet insert", + title: "TreeSet insert", input: [Int].self ) { input in - var set: ShareableSet = [] + var set: TreeSet = [] for i in input { set.insert(i) } @@ -92,10 +92,10 @@ extension Benchmark { } self.addSimple( - title: "ShareableSet insert, shared", + title: "TreeSet insert, shared", input: [Int].self ) { input in - var set: ShareableSet = [] + var set: TreeSet = [] for i in input { let copy = set set.insert(i) @@ -106,10 +106,10 @@ extension Benchmark { } self.addSimple( - title: "ShareableSet model diffing", + title: "TreeSet model diffing", input: Int.self ) { input in - typealias Model = ShareableSet + typealias Model = TreeSet var _state: Model = [] // Private func updateState( @@ -130,11 +130,11 @@ extension Benchmark { } self.add( - title: "ShareableSet remove", + title: "TreeSet remove", input: ([Int], [Int]).self ) { input, removals in return { timer in - var set = ShareableSet(input) + var set = TreeSet(input) for i in removals { set.remove(i) } @@ -144,11 +144,11 @@ extension Benchmark { } self.add( - title: "ShareableSet remove, shared", + title: "TreeSet remove, shared", input: ([Int], [Int]).self ) { input, removals in return { timer in - var set = ShareableSet(input) + var set = TreeSet(input) for i in removals { let copy = set set.remove(i) @@ -170,10 +170,10 @@ extension Benchmark { // SetAlgebra operations with Self do { func makeB( - _ a: ShareableSet, _ range: Range, shared: Bool - ) -> ShareableSet { + _ a: TreeSet, _ range: Range, shared: Bool + ) -> TreeSet { guard shared else { - return ShareableSet(range) + return TreeSet(range) } var b = a b.subtract(0 ..< range.lowerBound) @@ -186,11 +186,11 @@ extension Benchmark { let qualifier = "\(percentage) overlap, \(shared ? "shared" : "distinct")" self.add( - title: "ShareableSet union with Self (\(qualifier))", + title: "TreeSet union with Self (\(qualifier))", input: [Int].self ) { input in let start = start(input.count) - let a = ShareableSet(input) + let a = TreeSet(input) let b = makeB(a, start ..< start + input.count, shared: shared) return { timer in blackHole(a.union(identity(b))) @@ -198,11 +198,11 @@ extension Benchmark { } self.add( - title: "ShareableSet intersection with Self (\(qualifier))", + title: "TreeSet intersection with Self (\(qualifier))", input: [Int].self ) { input in let start = start(input.count) - let a = ShareableSet(input) + let a = TreeSet(input) let b = makeB(a, start ..< start + input.count, shared: shared) return { timer in blackHole(a.intersection(identity(b))) @@ -210,11 +210,11 @@ extension Benchmark { } self.add( - title: "ShareableSet symmetricDifference with Self (\(qualifier))", + title: "TreeSet symmetricDifference with Self (\(qualifier))", input: [Int].self ) { input in let start = start(input.count) - let a = ShareableSet(input) + let a = TreeSet(input) let b = makeB(a, start ..< start + input.count, shared: shared) return { timer in blackHole(a.symmetricDifference(identity(b))) @@ -222,11 +222,11 @@ extension Benchmark { } self.add( - title: "ShareableSet subtracting Self (\(qualifier))", + title: "TreeSet subtracting Self (\(qualifier))", input: [Int].self ) { input in let start = start(input.count) - let a = ShareableSet(input) + let a = TreeSet(input) let b = makeB(a, start ..< start + input.count, shared: shared) return { timer in blackHole(a.subtracting(identity(b))) @@ -240,11 +240,11 @@ extension Benchmark { do { for (percentage, start) in overlaps { self.add( - title: "ShareableSet union with Array (\(percentage) overlap)", + title: "TreeSet union with Array (\(percentage) overlap)", input: [Int].self ) { input in let start = start(input.count) - let a = ShareableSet(input) + let a = TreeSet(input) let b = Array(start ..< start + input.count) return { timer in blackHole(a.union(identity(b))) @@ -254,11 +254,11 @@ extension Benchmark { for (percentage, start) in overlaps { self.add( - title: "ShareableSet intersection with Array (\(percentage) overlap)", + title: "TreeSet intersection with Array (\(percentage) overlap)", input: [Int].self ) { input in let start = start(input.count) - let a = ShareableSet(input) + let a = TreeSet(input) let b = Array(start ..< start + input.count) return { timer in blackHole(a.intersection(identity(b))) @@ -268,11 +268,11 @@ extension Benchmark { for (percentage, start) in overlaps { self.add( - title: "ShareableSet symmetricDifference with Array (\(percentage) overlap)", + title: "TreeSet symmetricDifference with Array (\(percentage) overlap)", input: [Int].self ) { input in let start = start(input.count) - let a = ShareableSet(input) + let a = TreeSet(input) let b = Array(start ..< start + input.count) return { timer in blackHole(a.symmetricDifference(identity(b))) @@ -282,11 +282,11 @@ extension Benchmark { for (percentage, start) in overlaps { self.add( - title: "ShareableSet subtracting Array (\(percentage) overlap)", + title: "TreeSet subtracting Array (\(percentage) overlap)", input: [Int].self ) { input in let start = start(input.count) - let a = ShareableSet(input) + let a = TreeSet(input) let b = Array(start ..< start + input.count) return { timer in blackHole(a.subtracting(identity(b))) @@ -298,10 +298,10 @@ extension Benchmark { // SetAlgebra mutations with Self do { func makeB( - _ a: ShareableSet, _ range: Range, shared: Bool - ) -> ShareableSet { + _ a: TreeSet, _ range: Range, shared: Bool + ) -> TreeSet { guard shared else { - return ShareableSet(range) + return TreeSet(range) } var b = a b.subtract(0 ..< range.lowerBound) @@ -314,12 +314,12 @@ extension Benchmark { let qualifier = "\(percentage) overlap, \(shared ? "shared" : "distinct")" self.add( - title: "ShareableSet formUnion with Self (\(qualifier))", + title: "TreeSet formUnion with Self (\(qualifier))", input: [Int].self ) { input in let start = start(input.count) return { timer in - var a = ShareableSet(input) + var a = TreeSet(input) let b = makeB(a, start ..< start + input.count, shared: shared) timer.measure { a.formUnion(identity(b)) @@ -329,12 +329,12 @@ extension Benchmark { } self.add( - title: "ShareableSet formIntersection with Self (\(qualifier))", + title: "TreeSet formIntersection with Self (\(qualifier))", input: [Int].self ) { input in let start = start(input.count) return { timer in - var a = ShareableSet(input) + var a = TreeSet(input) let b = makeB(a, start ..< start + input.count, shared: shared) timer.measure { a.formIntersection(identity(b)) @@ -344,12 +344,12 @@ extension Benchmark { } self.add( - title: "ShareableSet formSymmetricDifference with Self (\(qualifier))", + title: "TreeSet formSymmetricDifference with Self (\(qualifier))", input: [Int].self ) { input in let start = start(input.count) return { timer in - var a = ShareableSet(input) + var a = TreeSet(input) let b = makeB(a, start ..< start + input.count, shared: shared) timer.measure { a.formSymmetricDifference(identity(b)) @@ -359,12 +359,12 @@ extension Benchmark { } self.add( - title: "ShareableSet subtract Self (\(qualifier))", + title: "TreeSet subtract Self (\(qualifier))", input: [Int].self ) { input in let start = start(input.count) return { timer in - var a = ShareableSet(input) + var a = TreeSet(input) let b = makeB(a, start ..< start + input.count, shared: shared) timer.measure { a.subtract(identity(b)) @@ -380,13 +380,13 @@ extension Benchmark { do { for (percentage, start) in overlaps { self.add( - title: "ShareableSet formUnion with Array (\(percentage) overlap)", + title: "TreeSet formUnion with Array (\(percentage) overlap)", input: [Int].self ) { input in let start = start(input.count) let b = Array(start ..< start + input.count) return { timer in - var a = ShareableSet(input) + var a = TreeSet(input) timer.measure { a.formUnion(identity(b)) } @@ -397,13 +397,13 @@ extension Benchmark { for (percentage, start) in overlaps { self.add( - title: "ShareableSet formIntersection with Array (\(percentage) overlap)", + title: "TreeSet formIntersection with Array (\(percentage) overlap)", input: [Int].self ) { input in let start = start(input.count) let b = Array(start ..< start + input.count) return { timer in - var a = ShareableSet(input) + var a = TreeSet(input) timer.measure { a.formIntersection(identity(b)) } @@ -414,13 +414,13 @@ extension Benchmark { for (percentage, start) in overlaps { self.add( - title: "ShareableSet formSymmetricDifference with Array (\(percentage) overlap)", + title: "TreeSet formSymmetricDifference with Array (\(percentage) overlap)", input: [Int].self ) { input in let start = start(input.count) let b = Array(start ..< start + input.count) return { timer in - var a = ShareableSet(input) + var a = TreeSet(input) timer.measure { a.formSymmetricDifference(identity(b)) } @@ -431,13 +431,13 @@ extension Benchmark { for (percentage, start) in overlaps { self.add( - title: "ShareableSet subtract Array (\(percentage) overlap)", + title: "TreeSet subtract Array (\(percentage) overlap)", input: [Int].self ) { input in let start = start(input.count) let b = Array(start ..< start + input.count) return { timer in - var a = ShareableSet(input) + var a = TreeSet(input) timer.measure { a.subtract(identity(b)) } diff --git a/Benchmarks/Sources/benchmark-tool/main.swift b/Benchmarks/Sources/benchmark-tool/main.swift index 333311a8..c364a8ee 100644 --- a/Benchmarks/Sources/benchmark-tool/main.swift +++ b/Benchmarks/Sources/benchmark-tool/main.swift @@ -29,13 +29,13 @@ benchmark.registerCustomGenerators() benchmark.addArrayBenchmarks() benchmark.addSetBenchmarks() benchmark.addDictionaryBenchmarks() -benchmark.addShareableDictionaryBenchmarks() +benchmark.addTreeDictionaryBenchmarks() benchmark.addDequeBenchmarks() benchmark.addOrderedSetBenchmarks() benchmark.addOrderedDictionaryBenchmarks() benchmark.addHeapBenchmarks() benchmark.addBitSetBenchmarks() -benchmark.addShareableSetBenchmarks() +benchmark.addTreeSetBenchmarks() benchmark.addCppBenchmarks() #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) benchmark.addFoundationBenchmarks() diff --git a/Benchmarks/Sources/memory-benchmark/MemoryBenchmarks.swift b/Benchmarks/Sources/memory-benchmark/MemoryBenchmarks.swift index 40635b27..9555a5c3 100644 --- a/Benchmarks/Sources/memory-benchmark/MemoryBenchmarks.swift +++ b/Benchmarks/Sources/memory-benchmark/MemoryBenchmarks.swift @@ -30,11 +30,11 @@ struct MemoryBenchmarks: ParsableCommand { var i = 0 var d: Dictionary = [:] - var pd: ShareableDictionary = [:] + var pd: TreeDictionary = [:] print(""" Size,"Dictionary",\ - "ShareableDictionary",\ + "TreeDictionary",\ "average node size",\ "average item depth" """) @@ -67,9 +67,9 @@ struct MemoryBenchmarks: ParsableCommand { complain(""" Averages: Dictionary: \(sumd / Double(sizes.count)) - ShareableDictionary: \(sump / Double(sizes.count)) + TreeDictionary: \(sump / Double(sizes.count)) - ShareableDictionary at 1M items: + TreeDictionary at 1M items: average node size: \(pstats.averageNodeSize) average item depth: \(pstats.averageItemDepth) average lookup chain length: \(pstats.averageLookupChainLength) diff --git a/Package.swift b/Package.swift index 2f2d13de..77ed5a92 100644 --- a/Package.swift +++ b/Package.swift @@ -52,7 +52,7 @@ let package = Package( .library(name: "DequeModule", targets: ["DequeModule"]), .library(name: "HeapModule", targets: ["HeapModule"]), .library(name: "OrderedCollections", targets: ["OrderedCollections"]), - .library(name: "ShareableHashedCollections", targets: ["ShareableHashedCollections"]), + .library(name: "HashTreeCollections", targets: ["HashTreeCollections"]), ], targets: [ .target( @@ -62,7 +62,7 @@ let package = Package( "DequeModule", "HeapModule", "OrderedCollections", - "ShareableHashedCollections", + "HashTreeCollections", ], exclude: ["CMakeLists.txt"], swiftSettings: settings), @@ -134,15 +134,15 @@ let package = Package( dependencies: ["OrderedCollections", "_CollectionsTestSupport"], swiftSettings: settings), - // ShareableSet, ShareableDictionary + // TreeSet, TreeDictionary .target( - name: "ShareableHashedCollections", + name: "HashTreeCollections", dependencies: ["_CollectionsUtilities"], exclude: ["CMakeLists.txt"], swiftSettings: settings), .testTarget( - name: "ShareableHashedCollectionsTests", - dependencies: ["ShareableHashedCollections", "_CollectionsTestSupport"], + name: "HashTreeCollectionsTests", + dependencies: ["HashTreeCollections", "_CollectionsTestSupport"], swiftSettings: settings), ] ) diff --git a/README.md b/README.md index b14dbd5c..8c6d6b87 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ The package currently provides the following implementations: - [`OrderedDictionary`][OrderedDictionary], an ordered variant of the standard `Dictionary`, providing similar benefits. -- [`ShareableSet`][ShareableSet] and [`ShareableDictionary`][ShareableDictionary], persistent hashed collections implementing Compressed Hash-Array Mapped Prefix Trees (CHAMP). These work similar to the standard `Set` and `Dictionary`, but they excel at use cases that mutate shared copies, offering dramatic memory savings and radical time improvements. +- [`TreeSet`][TreeSet] and [`TreeDictionary`][TreeDictionary], persistent hashed collections implementing Compressed Hash-Array Mapped Prefix Trees (CHAMP). These work similar to the standard `Set` and `Dictionary`, but they excel at use cases that mutate shared copies, offering dramatic memory savings and radical time improvements. [BitSet]: Documentation/BitSet.md [BitArray]: Documentation/BitArray.md @@ -28,8 +28,8 @@ The package currently provides the following implementations: [Heap]: Documentation/Heap.md [OrderedSet]: Documentation/OrderedSet.md [OrderedDictionary]: Documentation/OrderedDictionary.md -[ShareableSet]: Documentation/ShareableSet.md -[ShareableDictionary]: Documentation/ShareableDictionary.md +[TreeSet]: Documentation/TreeSet.md +[TreeDictionary]: Documentation/TreeDictionary.md The following data structures are currently being worked on but they aren't ready for inclusion in a tagged release: @@ -55,7 +55,7 @@ The Swift Collections package is source stable. The version numbers follow [Sema [semver]: https://semver.org -The public API of version 1.1 of the `swift-collections` package consists of non-underscored declarations that are marked `public` in the `Collections`, `BitCollections`, `DequeModule`, `HeapModule`, `OrderedCollections` and `ShareableHashedCollections` modules. +The public API of version 1.1 of the `swift-collections` package consists of non-underscored declarations that are marked `public` in the `Collections`, `BitCollections`, `DequeModule`, `HeapModule`, `OrderedCollections` and `HashTreeCollections` modules. Interfaces that aren't part of the public API may continue to change in any release, including patch releases. If you have a use case that requires using underscored APIs, please [submit a Feature Request][enhancement] describing it! We'd like the public interface to be as useful as possible -- although preferably without compromising safety or limiting future evolution. diff --git a/Sources/CMakeLists.txt b/Sources/CMakeLists.txt index 05839a57..ad81e77d 100644 --- a/Sources/CMakeLists.txt +++ b/Sources/CMakeLists.txt @@ -12,5 +12,5 @@ add_subdirectory(Collections) add_subdirectory(DequeModule) add_subdirectory(HeapModule) add_subdirectory(OrderedCollections) -add_subdirectory(ShareableHashedCollections) +add_subdirectory(HashTreeCollections) add_subdirectory(_CollectionsUtilities) diff --git a/Sources/Collections/CMakeLists.txt b/Sources/Collections/CMakeLists.txt index 86c8abda..59f65030 100644 --- a/Sources/Collections/CMakeLists.txt +++ b/Sources/Collections/CMakeLists.txt @@ -14,7 +14,7 @@ target_link_libraries(Collections PRIVATE DequeModule HeapModule OrderedCollections - ShareableHashedCollections + HashTreeCollections ) set_target_properties(Collections PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) diff --git a/Sources/Collections/Collections.docc/Collections.md b/Sources/Collections/Collections.docc/Collections.md index 99c301de..733249b7 100644 --- a/Sources/Collections/Collections.docc/Collections.md +++ b/Sources/Collections/Collections.docc/Collections.md @@ -32,7 +32,7 @@ - ``OrderedSet`` - ``OrderedDictionary`` -### Persistent Collections +### Persistent Hashed Collections -- ``ShareableSet`` -- ``ShareableDictionary`` +- ``TreeSet`` +- ``TreeDictionary`` diff --git a/Sources/Collections/Collections.docc/Extensions/ShareableDictionary.md b/Sources/Collections/Collections.docc/Extensions/ShareableDictionary.md index 65efd408..88b08dab 100644 --- a/Sources/Collections/Collections.docc/Extensions/ShareableDictionary.md +++ b/Sources/Collections/Collections.docc/Extensions/ShareableDictionary.md @@ -1,4 +1,4 @@ -# ``Collections/ShareableDictionary`` +# ``Collections/TreeDictionary`` @@ -11,13 +11,13 @@ ### Collection Views -`ShareableDictionary` provides the customary dictionary views, `keys` and +`TreeDictionary` provides the customary dictionary views, `keys` and `values`. These are collection types that are projections of the dictionary itself, with elements that match only the keys or values of the dictionary, respectively. The `Keys` view is notable in that it provides operations for subtracting and intersecting the keys of two dictionaries, allowing for easy detection of inserted and removed items between two snapshots of the same -dictionary. Because `ShareableDictionary` needs to invalidate indices on every +dictionary. Because `TreeDictionary` needs to invalidate indices on every mutation, its `Values` view is not a `MutableCollection`. - ``Keys-swift.struct`` @@ -52,11 +52,11 @@ mutation, its `Values` view is not a `MutableCollection`. ### Adding or Updating Keys and Values -Beyond the standard `updateValue(_:forKey:)` method, `ShareableDictionary` also +Beyond the standard `updateValue(_:forKey:)` method, `TreeDictionary` also provides additional `updateValue` variants that take closure arguments. These provide a more straightforward way to perform in-place mutations on dictionary values (compared to mutating values through the corresponding subscript -operation.) `ShareableDictionary` also provides the standard `merge` and +operation.) `TreeDictionary` also provides the standard `merge` and `merging` operations for combining dictionary values. - ``updateValue(_:forKey:)`` diff --git a/Sources/Collections/Collections.docc/Extensions/ShareableSet.md b/Sources/Collections/Collections.docc/Extensions/ShareableSet.md index 83a906df..5348aa15 100644 --- a/Sources/Collections/Collections.docc/Extensions/ShareableSet.md +++ b/Sources/Collections/Collections.docc/Extensions/ShareableSet.md @@ -1,11 +1,11 @@ -# ``Collections/ShareableSet`` +# ``Collections/TreeSet`` ### Implementation Details -`ShareableSet` and `ShareableDictionary` are based on a Swift adaptation +`TreeSet` and `TreeDictionary` are based on a Swift adaptation of the *Compressed Hash-Array Mapped Prefix Tree* (CHAMP) data structure. - Michael J Steindorfer and Jurgen J Vinju. Optimizing Hash-Array Mapped @@ -18,7 +18,7 @@ In this setup, the members of such a collection are organized into a tree data structure based on their hash values. For example, assuming 16 bit hash values sliced into 4-bit chunks, each node in the prefix tree would have sixteen slots (one for each digit), each of which may contain a member, a -child node reference, or it may be empty. A `ShareableSet` containing the +child node reference, or it may be empty. A `TreeSet` containing the three items `Maximo`, `Julia` and `Don Pablo` (with hash values of `0x2B65`, `0xA69F` and `0xADA1`, respectively) may be organized into a prefix tree of two nodes: @@ -65,7 +65,7 @@ share the same hash. Looking up a member in one of these nodes requires a linear search, so it is crucial that such collisions do not happen often. As long as `Element` properly implements `Hashable`, lookup operations in a -`ShareableSet` are expected to be able to decide whether the set contains a +`TreeSet` are expected to be able to decide whether the set contains a particular item by looking at no more than a constant number of items on average -- typically they will need to compare against just one member. @@ -102,7 +102,7 @@ average -- typically they will need to compare against just one member. All the standard combining operations (intersection, union, subtraction and symmetric difference) are supported, in both non-mutating and mutating forms. `SetAlgebra` only requires the ability to combine one set instance with another, -but `ShareableSet` follows the tradition established by `Set` in providing +but `TreeSet` follows the tradition established by `Set` in providing additional overloads to each operation that allow combining a set with additional types, including arbitrary sequences. @@ -140,11 +140,11 @@ additional types, including arbitrary sequences. ### Comparing Sets -`ShareableSet` supports all standard set comparisons (subset tests, superset +`TreeSet` supports all standard set comparisons (subset tests, superset tests, disjunctness test), including the customary overloads established by `Set`. As an additional extension, the `isEqualSet` family of member functions generalize the standard `==` operation to support checking whether a -`ShareableSet` consists of exactly the same members as an arbitrary sequence. +`TreeSet` consists of exactly the same members as an arbitrary sequence. Like `==`, the `isEqualSet` functions ignore element ordering and duplicates (if any). diff --git a/Sources/Collections/Collections.swift b/Sources/Collections/Collections.swift index d3889cc3..99ffc85c 100644 --- a/Sources/Collections/Collections.swift +++ b/Sources/Collections/Collections.swift @@ -13,4 +13,4 @@ @_exported import DequeModule @_exported import HeapModule @_exported import OrderedCollections -@_exported import ShareableHashedCollections +@_exported import HashTreeCollections diff --git a/Sources/HashTreeCollections/CMakeLists.txt b/Sources/HashTreeCollections/CMakeLists.txt new file mode 100644 index 00000000..c5690fbf --- /dev/null +++ b/Sources/HashTreeCollections/CMakeLists.txt @@ -0,0 +1,103 @@ +#[[ +This source file is part of the Swift Collections Open Source Project + +Copyright (c) 2022 Apple Inc. and the Swift project authors +Licensed under Apache License v2.0 with Runtime Library Exception + +See https://swift.org/LICENSE.txt for license information +#]] + +add_library(HashTreeCollections + "Node/_AncestorSlots.swift" + "Node/_Bitmap.swift" + "Node/_Bucket.swift" + "Node/_Hash.swift" + "Node/_HashTreeIterator.swift" + "Node/_HashTreeStatistics.swift" + "Node/_Level.swift" + "Node/_Node+Builder.swift" + "Node/_Node+Debugging.swift" + "Node/_Node+Initializers.swift" + "Node/_Node+Invariants.swift" + "Node/_Node+Lookups.swift" + "Node/_Node+Primitive Insertions.swift" + "Node/_Node+Primitive Removals.swift" + "Node/_Node+Primitive Replacement.swift" + "Node/_Node+Storage.swift" + "Node/_Node+Structural compactMapValues.swift" + "Node/_Node+Structural filter.swift" + "Node/_Node+Structural intersection.swift" + "Node/_Node+Structural isDisjoint.swift" + "Node/_Node+Structural isEqualSet.swift" + "Node/_Node+Structural isSubset.swift" + "Node/_Node+Structural mapValues.swift" + "Node/_Node+Structural merge.swift" + "Node/_Node+Structural subtracting.swift" + "Node/_Node+Structural symmetricDifference.swift" + "Node/_Node+Structural union.swift" + "Node/_Node+Subtree Insertions.swift" + "Node/_Node+Subtree Modify.swift" + "Node/_Node+Subtree Removals.swift" + "Node/_Node+UnsafeHandle.swift" + "Node/_Node.swift" + "Node/_RawNode+UnsafeHandle.swift" + "Node/_RawNode.swift" + "Node/_Slot.swift" + "Node/_Stack.swift" + "Node/_StorageHeader.swift" + "Node/_UnmanagedNode.swift" + "Node/_UnsafePath.swift" + "TreeDictionary/TreeDictionary+Codable.swift" + "TreeDictionary/TreeDictionary+Collection.swift" + "TreeDictionary/TreeDictionary+CustomReflectable.swift" + "TreeDictionary/TreeDictionary+Debugging.swift" + "TreeDictionary/TreeDictionary+Descriptions.swift" + "TreeDictionary/TreeDictionary+Equatable.swift" + "TreeDictionary/TreeDictionary+ExpressibleByDictionaryLiteral.swift" + "TreeDictionary/TreeDictionary+Filter.swift" + "TreeDictionary/TreeDictionary+Hashable.swift" + "TreeDictionary/TreeDictionary+Initializers.swift" + "TreeDictionary/TreeDictionary+Keys.swift" + "TreeDictionary/TreeDictionary+MapValues.swift" + "TreeDictionary/TreeDictionary+Merge.swift" + "TreeDictionary/TreeDictionary+Sendable.swift" + "TreeDictionary/TreeDictionary+Sequence.swift" + "TreeDictionary/TreeDictionary+Values.swift" + "TreeDictionary/TreeDictionary.swift" + "TreeSet/TreeSet+Codable.swift" + "TreeSet/TreeSet+Collection.swift" + "TreeSet/TreeSet+CustomReflectable.swift" + "TreeSet/TreeSet+Debugging.swift" + "TreeSet/TreeSet+Descriptions.swift" + "TreeSet/TreeSet+Equatable.swift" + "TreeSet/TreeSet+ExpressibleByArrayLiteral.swift" + "TreeSet/TreeSet+Extras.swift" + "TreeSet/TreeSet+Filter.swift" + "TreeSet/TreeSet+Hashable.swift" + "TreeSet/TreeSet+Sendable.swift" + "TreeSet/TreeSet+Sequence.swift" + "TreeSet/TreeSet+SetAlgebra Initializers.swift" + "TreeSet/TreeSet+SetAlgebra basics.swift" + "TreeSet/TreeSet+SetAlgebra formIntersection.swift" + "TreeSet/TreeSet+SetAlgebra formSymmetricDifference.swift" + "TreeSet/TreeSet+SetAlgebra formUnion.swift" + "TreeSet/TreeSet+SetAlgebra intersection.swift" + "TreeSet/TreeSet+SetAlgebra isDisjoint.swift" + "TreeSet/TreeSet+SetAlgebra isEqualSet.swift" + "TreeSet/TreeSet+SetAlgebra isStrictSubset.swift" + "TreeSet/TreeSet+SetAlgebra isStrictSuperset.swift" + "TreeSet/TreeSet+SetAlgebra isSubset.swift" + "TreeSet/TreeSet+SetAlgebra isSuperset.swift" + "TreeSet/TreeSet+SetAlgebra subtract.swift" + "TreeSet/TreeSet+SetAlgebra subtracting.swift" + "TreeSet/TreeSet+SetAlgebra symmetricDifference.swift" + "TreeSet/TreeSet+SetAlgebra union.swift" + "TreeSet/TreeSet.swift" + ) +target_link_libraries(HashTreeCollections PRIVATE + _CollectionsUtilities) +set_target_properties(HashTreeCollections PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) + +_install_target(HashTreeCollections) +set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS HashTreeCollections) diff --git a/Sources/ShareableHashedCollections/ShareableHashedCollections.docc/Extensions/ShareableDictionary.md b/Sources/HashTreeCollections/HashTreeCollections.docc/Extensions/TreeDictionary.md similarity index 84% rename from Sources/ShareableHashedCollections/ShareableHashedCollections.docc/Extensions/ShareableDictionary.md rename to Sources/HashTreeCollections/HashTreeCollections.docc/Extensions/TreeDictionary.md index 96895b8c..0322d44a 100644 --- a/Sources/ShareableHashedCollections/ShareableHashedCollections.docc/Extensions/ShareableDictionary.md +++ b/Sources/HashTreeCollections/HashTreeCollections.docc/Extensions/TreeDictionary.md @@ -1,4 +1,4 @@ -# ``ShareableHashedCollections/ShareableDictionary`` +# ``HashTreeCollections/TreeDictionary`` @@ -8,13 +8,13 @@ ### Collection Views -`ShareableDictionary` provides the customary dictionary views, `keys` and +`TreeDictionary` provides the customary dictionary views, `keys` and `values`. These are collection types that are projections of the dictionary itself, with elements that match only the keys or values of the dictionary, respectively. The `Keys` view is notable in that it provides operations for subtracting and intersecting the keys of two dictionaries, allowing for easy detection of inserted and removed items between two snapshots of the same -dictionary. Because `ShareableDictionary` needs to invalidate indices on every +dictionary. Because `TreeDictionary` needs to invalidate indices on every mutation, its `Values` view is not a `MutableCollection`. - ``Keys-swift.struct`` @@ -49,11 +49,11 @@ mutation, its `Values` view is not a `MutableCollection`. ### Adding or Updating Keys and Values -Beyond the standard `updateValue(_:forKey:)` method, `ShareableDictionary` also +Beyond the standard `updateValue(_:forKey:)` method, `TreeDictionary` also provides additional `updateValue` variants that take closure arguments. These provide a more straightforward way to perform in-place mutations on dictionary values (compared to mutating values through the corresponding subscript -operation.) `ShareableDictionary` also provides the standard `merge` and +operation.) `TreeDictionary` also provides the standard `merge` and `merging` operations for combining dictionary values. - ``updateValue(_:forKey:)`` diff --git a/Sources/ShareableHashedCollections/ShareableHashedCollections.docc/Extensions/ShareableSet.md b/Sources/HashTreeCollections/HashTreeCollections.docc/Extensions/TreeSet.md similarity index 92% rename from Sources/ShareableHashedCollections/ShareableHashedCollections.docc/Extensions/ShareableSet.md rename to Sources/HashTreeCollections/HashTreeCollections.docc/Extensions/TreeSet.md index 23bd8ce8..f7e629b6 100644 --- a/Sources/ShareableHashedCollections/ShareableHashedCollections.docc/Extensions/ShareableSet.md +++ b/Sources/HashTreeCollections/HashTreeCollections.docc/Extensions/TreeSet.md @@ -1,8 +1,8 @@ -# ``ShareableHashedCollections/ShareableSet`` +# ``HashTreeCollections/TreeSet`` ### Implementation Details -`ShareableSet` and `ShareableDictionary` are based on a Swift adaptation +`TreeSet` and `TreeDictionary` are based on a Swift adaptation of the *Compressed Hash-Array Mapped Prefix Tree* (CHAMP) data structure. - Michael J Steindorfer and Jurgen J Vinju. Optimizing Hash-Array Mapped @@ -15,7 +15,7 @@ In this setup, the members of such a collection are organized into a tree data structure based on their hash values. For example, assuming 16 bit hash values sliced into 4-bit chunks, each node in the prefix tree would have sixteen slots (one for each digit), each of which may contain a member, a -child node reference, or it may be empty. A `ShareableSet` containing the +child node reference, or it may be empty. A `TreeSet` containing the three items `Maximo`, `Julia` and `Don Pablo` (with hash values of `0x2B65`, `0xA69F` and `0xADA1`, respectively) may be organized into a prefix tree of two nodes: @@ -62,7 +62,7 @@ share the same hash. Looking up a member in one of these nodes requires a linear search, so it is crucial that such collisions do not happen often. As long as `Element` properly implements `Hashable`, lookup operations in a -`ShareableSet` are expected to be able to decide whether the set contains a +`TreeSet` are expected to be able to decide whether the set contains a particular item by looking at no more than a constant number of items on average -- typically they will need to compare against just one member. @@ -99,7 +99,7 @@ average -- typically they will need to compare against just one member. All the standard combining operations (intersection, union, subtraction and symmetric difference) are supported, in both non-mutating and mutating forms. `SetAlgebra` only requires the ability to combine one set instance with another, -but `ShareableSet` follows the tradition established by `Set` in providing +but `TreeSet` follows the tradition established by `Set` in providing additional overloads to each operation that allow combining a set with additional types, including arbitrary sequences. @@ -137,11 +137,11 @@ additional types, including arbitrary sequences. ### Comparing Sets -`ShareableSet` supports all standard set comparisons (subset tests, superset +`TreeSet` supports all standard set comparisons (subset tests, superset tests, disjunctness test), including the customary overloads established by `Set`. As an additional extension, the `isEqualSet` family of member functions generalize the standard `==` operation to support checking whether a -`ShareableSet` consists of exactly the same members as an arbitrary sequence. +`TreeSet` consists of exactly the same members as an arbitrary sequence. Like `==`, the `isEqualSet` functions ignore element ordering and duplicates (if any). diff --git a/Sources/ShareableHashedCollections/ShareableHashedCollections.docc/ShareableHashedCollections.md b/Sources/HashTreeCollections/HashTreeCollections.docc/HashTreeCollections.md similarity index 83% rename from Sources/ShareableHashedCollections/ShareableHashedCollections.docc/ShareableHashedCollections.md rename to Sources/HashTreeCollections/HashTreeCollections.docc/HashTreeCollections.md index 44c795e3..9d3a927b 100644 --- a/Sources/ShareableHashedCollections/ShareableHashedCollections.docc/ShareableHashedCollections.md +++ b/Sources/HashTreeCollections/HashTreeCollections.docc/HashTreeCollections.md @@ -1,4 +1,4 @@ -# ``ShareableHashedCollections`` +# ``HashTreeCollections`` **Swift Collections** is an open-source package of data structure implementations for the Swift programming language. @@ -16,5 +16,5 @@ ### Persistent Collections -- ``ShareableSet`` -- ``ShareableDictionary`` +- ``TreeSet`` +- ``TreeDictionary`` diff --git a/Sources/ShareableHashedCollections/Node/_AncestorSlots.swift b/Sources/HashTreeCollections/Node/_AncestorSlots.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_AncestorSlots.swift rename to Sources/HashTreeCollections/Node/_AncestorSlots.swift diff --git a/Sources/ShareableHashedCollections/Node/_Bitmap.swift b/Sources/HashTreeCollections/Node/_Bitmap.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Bitmap.swift rename to Sources/HashTreeCollections/Node/_Bitmap.swift diff --git a/Sources/ShareableHashedCollections/Node/_Bucket.swift b/Sources/HashTreeCollections/Node/_Bucket.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Bucket.swift rename to Sources/HashTreeCollections/Node/_Bucket.swift diff --git a/Sources/ShareableHashedCollections/Node/_Hash.swift b/Sources/HashTreeCollections/Node/_Hash.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Hash.swift rename to Sources/HashTreeCollections/Node/_Hash.swift diff --git a/Sources/ShareableHashedCollections/Node/_HashTreeIterator.swift b/Sources/HashTreeCollections/Node/_HashTreeIterator.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_HashTreeIterator.swift rename to Sources/HashTreeCollections/Node/_HashTreeIterator.swift diff --git a/Sources/ShareableHashedCollections/Node/_HashTreeStatistics.swift b/Sources/HashTreeCollections/Node/_HashTreeStatistics.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_HashTreeStatistics.swift rename to Sources/HashTreeCollections/Node/_HashTreeStatistics.swift diff --git a/Sources/ShareableHashedCollections/Node/_Level.swift b/Sources/HashTreeCollections/Node/_Level.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Level.swift rename to Sources/HashTreeCollections/Node/_Level.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Builder.swift b/Sources/HashTreeCollections/Node/_Node+Builder.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Builder.swift rename to Sources/HashTreeCollections/Node/_Node+Builder.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Debugging.swift b/Sources/HashTreeCollections/Node/_Node+Debugging.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Debugging.swift rename to Sources/HashTreeCollections/Node/_Node+Debugging.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Initializers.swift b/Sources/HashTreeCollections/Node/_Node+Initializers.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Initializers.swift rename to Sources/HashTreeCollections/Node/_Node+Initializers.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Invariants.swift b/Sources/HashTreeCollections/Node/_Node+Invariants.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Invariants.swift rename to Sources/HashTreeCollections/Node/_Node+Invariants.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Lookups.swift b/Sources/HashTreeCollections/Node/_Node+Lookups.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Lookups.swift rename to Sources/HashTreeCollections/Node/_Node+Lookups.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Primitive Insertions.swift b/Sources/HashTreeCollections/Node/_Node+Primitive Insertions.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Primitive Insertions.swift rename to Sources/HashTreeCollections/Node/_Node+Primitive Insertions.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Primitive Removals.swift b/Sources/HashTreeCollections/Node/_Node+Primitive Removals.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Primitive Removals.swift rename to Sources/HashTreeCollections/Node/_Node+Primitive Removals.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Primitive Replacement.swift b/Sources/HashTreeCollections/Node/_Node+Primitive Replacement.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Primitive Replacement.swift rename to Sources/HashTreeCollections/Node/_Node+Primitive Replacement.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Storage.swift b/Sources/HashTreeCollections/Node/_Node+Storage.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Storage.swift rename to Sources/HashTreeCollections/Node/_Node+Storage.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural compactMapValues.swift b/Sources/HashTreeCollections/Node/_Node+Structural compactMapValues.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural compactMapValues.swift rename to Sources/HashTreeCollections/Node/_Node+Structural compactMapValues.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural filter.swift b/Sources/HashTreeCollections/Node/_Node+Structural filter.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural filter.swift rename to Sources/HashTreeCollections/Node/_Node+Structural filter.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural intersection.swift b/Sources/HashTreeCollections/Node/_Node+Structural intersection.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural intersection.swift rename to Sources/HashTreeCollections/Node/_Node+Structural intersection.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural isDisjoint.swift b/Sources/HashTreeCollections/Node/_Node+Structural isDisjoint.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural isDisjoint.swift rename to Sources/HashTreeCollections/Node/_Node+Structural isDisjoint.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural isEqualSet.swift b/Sources/HashTreeCollections/Node/_Node+Structural isEqualSet.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural isEqualSet.swift rename to Sources/HashTreeCollections/Node/_Node+Structural isEqualSet.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural isSubset.swift b/Sources/HashTreeCollections/Node/_Node+Structural isSubset.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural isSubset.swift rename to Sources/HashTreeCollections/Node/_Node+Structural isSubset.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural mapValues.swift b/Sources/HashTreeCollections/Node/_Node+Structural mapValues.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural mapValues.swift rename to Sources/HashTreeCollections/Node/_Node+Structural mapValues.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural merge.swift b/Sources/HashTreeCollections/Node/_Node+Structural merge.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural merge.swift rename to Sources/HashTreeCollections/Node/_Node+Structural merge.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural subtracting.swift b/Sources/HashTreeCollections/Node/_Node+Structural subtracting.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural subtracting.swift rename to Sources/HashTreeCollections/Node/_Node+Structural subtracting.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural symmetricDifference.swift b/Sources/HashTreeCollections/Node/_Node+Structural symmetricDifference.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural symmetricDifference.swift rename to Sources/HashTreeCollections/Node/_Node+Structural symmetricDifference.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Structural union.swift b/Sources/HashTreeCollections/Node/_Node+Structural union.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Structural union.swift rename to Sources/HashTreeCollections/Node/_Node+Structural union.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Subtree Insertions.swift b/Sources/HashTreeCollections/Node/_Node+Subtree Insertions.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Subtree Insertions.swift rename to Sources/HashTreeCollections/Node/_Node+Subtree Insertions.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Subtree Modify.swift b/Sources/HashTreeCollections/Node/_Node+Subtree Modify.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Subtree Modify.swift rename to Sources/HashTreeCollections/Node/_Node+Subtree Modify.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+Subtree Removals.swift b/Sources/HashTreeCollections/Node/_Node+Subtree Removals.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+Subtree Removals.swift rename to Sources/HashTreeCollections/Node/_Node+Subtree Removals.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node+UnsafeHandle.swift b/Sources/HashTreeCollections/Node/_Node+UnsafeHandle.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node+UnsafeHandle.swift rename to Sources/HashTreeCollections/Node/_Node+UnsafeHandle.swift diff --git a/Sources/ShareableHashedCollections/Node/_Node.swift b/Sources/HashTreeCollections/Node/_Node.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Node.swift rename to Sources/HashTreeCollections/Node/_Node.swift diff --git a/Sources/ShareableHashedCollections/Node/_RawNode+UnsafeHandle.swift b/Sources/HashTreeCollections/Node/_RawNode+UnsafeHandle.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_RawNode+UnsafeHandle.swift rename to Sources/HashTreeCollections/Node/_RawNode+UnsafeHandle.swift diff --git a/Sources/ShareableHashedCollections/Node/_RawNode.swift b/Sources/HashTreeCollections/Node/_RawNode.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_RawNode.swift rename to Sources/HashTreeCollections/Node/_RawNode.swift diff --git a/Sources/ShareableHashedCollections/Node/_Slot.swift b/Sources/HashTreeCollections/Node/_Slot.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_Slot.swift rename to Sources/HashTreeCollections/Node/_Slot.swift diff --git a/Sources/ShareableHashedCollections/Node/_Stack.swift b/Sources/HashTreeCollections/Node/_Stack.swift similarity index 99% rename from Sources/ShareableHashedCollections/Node/_Stack.swift rename to Sources/HashTreeCollections/Node/_Stack.swift index de443adc..bbf9c962 100644 --- a/Sources/ShareableHashedCollections/Node/_Stack.swift +++ b/Sources/HashTreeCollections/Node/_Stack.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// /// A fixed-size array of just enough size to hold an ancestor path in a -/// `ShareableDictionary`. +/// `TreeDictionary`. @usableFromInline @frozen internal struct _Stack { diff --git a/Sources/ShareableHashedCollections/Node/_StorageHeader.swift b/Sources/HashTreeCollections/Node/_StorageHeader.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_StorageHeader.swift rename to Sources/HashTreeCollections/Node/_StorageHeader.swift diff --git a/Sources/ShareableHashedCollections/Node/_UnmanagedNode.swift b/Sources/HashTreeCollections/Node/_UnmanagedNode.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_UnmanagedNode.swift rename to Sources/HashTreeCollections/Node/_UnmanagedNode.swift diff --git a/Sources/ShareableHashedCollections/Node/_UnsafePath.swift b/Sources/HashTreeCollections/Node/_UnsafePath.swift similarity index 100% rename from Sources/ShareableHashedCollections/Node/_UnsafePath.swift rename to Sources/HashTreeCollections/Node/_UnsafePath.swift diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Codable.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Codable.swift similarity index 97% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Codable.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Codable.swift index 424651fe..7a9d4246 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Codable.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Codable.swift @@ -11,7 +11,7 @@ // Code in this file is a slightly adapted variant of `Dictionary`'s `Codable` // implementation in the Standard Library as of Swift 5.7. -// `ShareableDictionary` therefore encodes/decodes itself exactly the same as +// `TreeDictionary` therefore encodes/decodes itself exactly the same as // `Dictionary`, and the two types can each decode data encoded by the other. /// A wrapper for dictionary keys which are Strings or Ints. @@ -35,7 +35,7 @@ internal struct _DictionaryCodingKey: CodingKey { } } -extension ShareableDictionary: Encodable +extension TreeDictionary: Encodable where Key: Encodable, Value: Encodable { /// Encodes the elements of this dictionary into the given encoder. @@ -85,7 +85,7 @@ where Key: Encodable, Value: Encodable } } -extension ShareableDictionary: Decodable +extension TreeDictionary: Decodable where Key: Decodable, Value: Decodable { /// Creates a new dictionary by decoding from the given decoder. diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Collection.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Collection.swift similarity index 92% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Collection.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Collection.swift index e84b3902..e05279f2 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Collection.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Collection.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary { +extension TreeDictionary { /// The position of an element in a persistent dictionary. /// /// An index in a persistent dictionary is a compact encoding of a path in @@ -39,11 +39,11 @@ extension ShareableDictionary { } #if swift(>=5.5) -extension ShareableDictionary.Index: @unchecked Sendable +extension TreeDictionary.Index: @unchecked Sendable where Key: Sendable, Value: Sendable {} #endif -extension ShareableDictionary.Index: Equatable { +extension TreeDictionary.Index: Equatable { /// Returns a Boolean value indicating whether two index values are equal. /// /// Note that comparing two indices that do not belong to the same tree @@ -59,7 +59,7 @@ extension ShareableDictionary.Index: Equatable { } } -extension ShareableDictionary.Index: Comparable { +extension TreeDictionary.Index: Comparable { /// Returns a Boolean value indicating whether the value of the first argument /// is less than the second argument. /// @@ -75,7 +75,7 @@ extension ShareableDictionary.Index: Comparable { } } -extension ShareableDictionary.Index: Hashable { +extension TreeDictionary.Index: Hashable { /// Hashes the essential components of this value by feeding them into the /// given hasher. /// @@ -86,21 +86,21 @@ extension ShareableDictionary.Index: Hashable { } } -extension ShareableDictionary.Index: CustomStringConvertible { +extension TreeDictionary.Index: CustomStringConvertible { // A textual representation of this instance. public var description: String { _path.description } } -extension ShareableDictionary.Index: CustomDebugStringConvertible { +extension TreeDictionary.Index: CustomDebugStringConvertible { /// A textual representation of this instance, suitable for debugging. public var debugDescription: String { _path.description } } -extension ShareableDictionary: Collection { +extension TreeDictionary: Collection { /// A Boolean value indicating whether the collection is empty. /// /// - Complexity: O(1) @@ -198,7 +198,7 @@ extension ShareableDictionary: Collection { /// - Parameter start: A valid index of the collection. /// - Parameter end: Another valid index of the collection. /// - Returns: The distance between `start` and `end`. - /// (The result can be negative, even though `ShareableDictionary` is not + /// (The result can be negative, even though `TreeDictionary` is not /// a bidirectional collection.) /// - Complexity: O(log(`count`)) @inlinable @@ -216,7 +216,7 @@ extension ShareableDictionary: Collection { /// - i: A valid index of the collection. /// - distance: The distance to offset `i`. As a special exception, /// `distance` is allowed to be negative even though - /// `ShareableDictionary` isn't a bidirectional collection. + /// `TreeDictionary` isn't a bidirectional collection. /// - Returns: An index offset by `distance` from the index `i`. If /// `distance` is positive, this is the same value as the result of /// `distance` calls to `index(after:)`. If distance is negative, then @@ -244,7 +244,7 @@ extension ShareableDictionary: Collection { /// - i: A valid index of the collection. /// - distance: The distance to offset `i`. As a special exception, /// `distance` is allowed to be negative even though - /// `ShareableDictionary` isn't a bidirectional collection. + /// `TreeDictionary` isn't a bidirectional collection. /// - limit: A valid index of the collection to use as a limit. If /// `distance > 0`, a limit that is less than `i` has no effect. /// Likewise, if `distance < 0`, a limit that is greater than `i` has no @@ -273,8 +273,8 @@ extension ShareableDictionary: Collection { #if false // Note: Let's not do this. `BidirectionalCollection` would imply that // the ordering of elements would be meaningful, which isn't true for -// `ShareableDictionary`. -extension ShareableDictionary: BidirectionalCollection { +// `TreeDictionary`. +extension TreeDictionary: BidirectionalCollection { /// Replaces the given index with its predecessor. /// /// - Parameter i: A valid index of the collection. diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+CustomReflectable.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+CustomReflectable.swift similarity index 92% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+CustomReflectable.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+CustomReflectable.swift index 481970d7..9e946b6d 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+CustomReflectable.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+CustomReflectable.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary: CustomReflectable { +extension TreeDictionary: CustomReflectable { /// The custom mirror for this instance. public var customMirror: Mirror { Mirror(self, unlabeledChildren: self, displayStyle: .dictionary) diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Debugging.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Debugging.swift similarity index 97% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Debugging.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Debugging.swift index 5c3a552a..17a6c52a 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Debugging.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Debugging.swift @@ -11,7 +11,7 @@ import _CollectionsUtilities -extension ShareableDictionary { +extension TreeDictionary { /// True if consistency checking is enabled in the implementation of this /// type, false otherwise. /// diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Descriptions.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Descriptions.swift similarity index 83% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Descriptions.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Descriptions.swift index cb986ec0..e0c1eca6 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Descriptions.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Descriptions.swift @@ -11,14 +11,14 @@ import _CollectionsUtilities -extension ShareableDictionary: CustomStringConvertible { +extension TreeDictionary: CustomStringConvertible { // A textual representation of this instance. public var description: String { _dictionaryDescription(for: self) } } -extension ShareableDictionary: CustomDebugStringConvertible { +extension TreeDictionary: CustomDebugStringConvertible { /// A textual representation of this instance, suitable for debugging. public var debugDescription: String { _dictionaryDescription( @@ -26,6 +26,6 @@ extension ShareableDictionary: CustomDebugStringConvertible { } internal static func _debugTypeName() -> String { - "ShareableDictionary<\(Key.self), \(Value.self)>" + "TreeDictionary<\(Key.self), \(Value.self)>" } } diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Equatable.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Equatable.swift similarity index 92% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Equatable.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Equatable.swift index 8a745e04..517a63f6 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Equatable.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Equatable.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary: Equatable where Value: Equatable { +extension TreeDictionary: Equatable where Value: Equatable { /// Returns a Boolean value indicating whether two values are equal. /// /// Two persistent dictionaries are considered equal if they contain the same diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+ExpressibleByDictionaryLiteral.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+ExpressibleByDictionaryLiteral.swift similarity index 95% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+ExpressibleByDictionaryLiteral.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+ExpressibleByDictionaryLiteral.swift index e9776d8f..6b3ae8c8 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+ExpressibleByDictionaryLiteral.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+ExpressibleByDictionaryLiteral.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary: ExpressibleByDictionaryLiteral { +extension TreeDictionary: ExpressibleByDictionaryLiteral { /// Creates a new dictionary from the contents of a dictionary literal. /// /// The literal must not contain duplicate elements. diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Filter.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Filter.swift similarity index 92% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Filter.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Filter.swift index 7fcb2bbb..af7b1e67 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Filter.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Filter.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary { +extension TreeDictionary { /// Returns a new persistent dictionary containing the key-value pairs of this /// dictionary that satisfy the given predicate. /// @@ -26,7 +26,7 @@ extension ShareableDictionary { ) rethrows -> Self { let result = try _root.filter(.top, isIncluded) guard let result = result else { return self } - return ShareableDictionary(_new: result.finalize(.top)) + return TreeDictionary(_new: result.finalize(.top)) } /// Removes all the elements that satisfy the given predicate. @@ -36,7 +36,7 @@ extension ShareableDictionary { /// This example removes all the odd valued items from a /// dictionary mapping strings to numbers: /// - /// var numbers: ShareableDictionary = ["a": 5, "b": 6, "c": 7, "d": 8] + /// var numbers: TreeDictionary = ["a": 5, "b": 6, "c": 7, "d": 8] /// numbers.removeAll(where: { $0.value % 2 != 0 }) /// // numbers == ["b": 6, "d": 8] /// diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Hashable.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Hashable.swift similarity index 93% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Hashable.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Hashable.swift index 8e27d527..175eebbf 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Hashable.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Hashable.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary: Hashable where Value: Hashable { +extension TreeDictionary: Hashable where Value: Hashable { /// Hashes the essential components of this value by feeding them into the /// given hasher. /// diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Initializers.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Initializers.swift similarity index 95% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Initializers.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Initializers.swift index d4780053..461cc254 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Initializers.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Initializers.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary { +extension TreeDictionary { /// Creates an empty dictionary. /// /// This initializer is equivalent to initializing with an empty dictionary @@ -25,7 +25,7 @@ extension ShareableDictionary { /// /// - Complexity: O(1) @inlinable - public init(_ other: ShareableDictionary) { + public init(_ other: TreeDictionary) { self = other } @@ -45,7 +45,7 @@ extension ShareableDictionary { /// - Complexity: O(`other.count`) @inlinable public init( - keys: ShareableSet, + keys: TreeSet, valueGenerator valueTransform: (Key) throws -> Value ) rethrows { // FIXME: This is a non-standard addition @@ -144,12 +144,12 @@ extension ShareableDictionary { /// /// let pairsWithDuplicateKeys = [("a", 1), ("b", 2), ("a", 3), ("b", 4)] /// - /// let firstValues = ShareableDictionary( + /// let firstValues = TreeDictionary( /// pairsWithDuplicateKeys, /// uniquingKeysWith: { (first, _) in first }) /// // ["a": 1, "b": 2] /// - /// let lastValues = ShareableDictionary( + /// let lastValues = TreeDictionary( /// pairsWithDuplicateKeys, /// uniquingKeysWith: { (_, last) in last }) /// // ["a": 3, "b": 4] @@ -183,12 +183,12 @@ extension ShareableDictionary { /// /// let pairsWithDuplicateKeys = [("a", 1), ("b", 2), ("a", 3), ("b", 4)] /// - /// let firstValues = ShareableDictionary( + /// let firstValues = TreeDictionary( /// pairsWithDuplicateKeys, /// uniquingKeysWith: { (first, _) in first }) /// // ["a": 1, "b": 2] /// - /// let lastValues = ShareableDictionary( + /// let lastValues = TreeDictionary( /// pairsWithDuplicateKeys, /// uniquingKeysWith: { (_, last) in last }) /// // ["a": 3, "b": 4] @@ -212,7 +212,7 @@ extension ShareableDictionary { } } -extension ShareableDictionary { +extension TreeDictionary { /// Creates a new dictionary whose keys are the groupings returned by the /// given closure and whose values are arrays of the elements that returned /// each key. @@ -225,7 +225,7 @@ extension ShareableDictionary { /// dictionary from that array by grouping the names by first letter: /// /// let students = ["Kofi", "Abena", "Efua", "Kweku", "Akosua"] - /// let studentsByLetter = ShareableDictionary(grouping: students, by: { $0.first! }) + /// let studentsByLetter = TreeDictionary(grouping: students, by: { $0.first! }) /// // ["K": ["Kofi", "Kweku"], "A": ["Abena", "Akosua"], "E": ["Efua"]] /// /// The new `studentsByLetter` dictionary has three entries, with students' @@ -260,7 +260,7 @@ extension ShareableDictionary { /// dictionary from that array by grouping the names by first letter: /// /// let students = ["Kofi", "Abena", "Efua", "Kweku", "Akosua"] - /// let studentsByLetter = ShareableDictionary(grouping: students, by: { $0.first! }) + /// let studentsByLetter = TreeDictionary(grouping: students, by: { $0.first! }) /// // ["K": ["Kofi", "Kweku"], "A": ["Abena", "Akosua"], "E": ["Efua"]] /// /// The new `studentsByLetter` dictionary has three entries, with students' diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Keys.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Keys.swift similarity index 80% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Keys.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Keys.swift index 2143e178..7ee029d2 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Keys.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Keys.swift @@ -11,18 +11,18 @@ import _CollectionsUtilities -extension ShareableDictionary { +extension TreeDictionary { /// A view of a persistent dictionary’s keys, as a standalone collection. @frozen public struct Keys { @usableFromInline - internal typealias _Node = ShareableHashedCollections._Node + internal typealias _Node = HashTreeCollections._Node @usableFromInline - internal var _base: ShareableDictionary + internal var _base: TreeDictionary @inlinable - internal init(_base: ShareableDictionary) { + internal init(_base: TreeDictionary) { self._base = _base } } @@ -37,30 +37,30 @@ extension ShareableDictionary { } #if swift(>=5.5) -extension ShareableDictionary.Keys: Sendable +extension TreeDictionary.Keys: Sendable where Key: Sendable, Value: Sendable {} #endif -extension ShareableDictionary.Keys: _UniqueCollection {} +extension TreeDictionary.Keys: _UniqueCollection {} -extension ShareableDictionary.Keys: CustomStringConvertible { +extension TreeDictionary.Keys: CustomStringConvertible { // A textual representation of this instance. public var description: String { _arrayDescription(for: self) } } -extension ShareableDictionary.Keys: CustomDebugStringConvertible { +extension TreeDictionary.Keys: CustomDebugStringConvertible { /// A textual representation of this instance, suitable for debugging. public var debugDescription: String { _arrayDescription( for: self, debug: true, - typeName: "\(ShareableDictionary._debugTypeName()).Keys") + typeName: "\(TreeDictionary._debugTypeName()).Keys") } } -extension ShareableDictionary.Keys: Sequence { +extension TreeDictionary.Keys: Sequence { /// The element type of the collection. public typealias Element = Key @@ -71,10 +71,10 @@ extension ShareableDictionary.Keys: Sequence { public typealias Element = Key @usableFromInline - internal var _base: ShareableDictionary.Iterator + internal var _base: TreeDictionary.Iterator @inlinable - internal init(_base: ShareableDictionary.Iterator) { + internal init(_base: TreeDictionary.Iterator) { self._base = _base } @@ -113,12 +113,12 @@ extension ShareableDictionary.Keys: Sequence { } #if swift(>=5.5) -extension ShareableDictionary.Keys.Iterator: Sendable +extension TreeDictionary.Keys.Iterator: Sendable where Key: Sendable, Value: Sendable {} #endif -extension ShareableDictionary.Keys: Collection { - public typealias Index = ShareableDictionary.Index +extension TreeDictionary.Keys: Collection { + public typealias Index = TreeDictionary.Index @inlinable public var isEmpty: Bool { _base.isEmpty } @@ -166,10 +166,10 @@ extension ShareableDictionary.Keys: Collection { } #if false -extension ShareableDictionary.Keys: BidirectionalCollection { +extension TreeDictionary.Keys: BidirectionalCollection { // Note: Let's not do this. `BidirectionalCollection` would imply that // the ordering of elements would be meaningful, which isn't true for - // `ShareableDictionary.Keys`. + // `TreeDictionary.Keys`. @inlinable public func formIndex(before i: inout Index) { _base.formIndex(before: &i) @@ -182,12 +182,12 @@ extension ShareableDictionary.Keys: BidirectionalCollection { } #endif -extension ShareableDictionary.Keys { +extension TreeDictionary.Keys { /// Returns a new keys view with the elements that are common to both this /// view and the provided other one. /// - /// var a: ShareableDictionary = ["a": 1, "b": 2, "c": 3] - /// let b: ShareableDictionary = ["b": 4, "d": 5, "e": 6] + /// var a: TreeDictionary = ["a": 1, "b": 2, "c": 3] + /// let b: TreeDictionary = ["b": 4, "d": 5, "e": 6] /// let c = a.keys.intersection(b.keys) /// // `c` is `["b"]` /// @@ -204,19 +204,19 @@ extension ShareableDictionary.Keys { /// hash tree structure to minimize work when possible, e.g. by linking /// parts of the input trees directly into the result. public func intersection( - _ other: ShareableDictionary.Keys + _ other: TreeDictionary.Keys ) -> Self { guard let r = _base._root.intersection(.top, other._base._root) else { return self } - return ShareableDictionary(_new: r).keys + return TreeDictionary(_new: r).keys } /// Returns a new keys view with the elements that are common to both this /// view and the provided persistent set. /// - /// var a: ShareableDictionary = ["a": 1, "b": 2, "c": 3] - /// let b: ShareableSet = ["b", "d", "e"] + /// var a: TreeDictionary = ["a": 1, "b": 2, "c": 3] + /// let b: TreeSet = ["b", "d", "e"] /// let c = a.keys.intersection(b) /// // `c` is `["b"]` /// @@ -231,18 +231,18 @@ extension ShareableDictionary.Keys { /// However, the implementation is careful to make the best use of /// hash tree structure to minimize work when possible, e.g. by linking /// parts of the input trees directly into the result. - public func intersection(_ other: ShareableSet) -> Self { + public func intersection(_ other: TreeSet) -> Self { guard let r = _base._root.intersection(.top, other._root) else { return self } - return ShareableDictionary(_new: r).keys + return TreeDictionary(_new: r).keys } /// Returns a new keys view containing the elements of `self` that do not /// occur in the provided other one. /// - /// var a: ShareableDictionary = ["a": 1, "b": 2, "c": 3] - /// let b: ShareableDictionary = ["b": 4, "d": 5, "e": 6] + /// var a: TreeDictionary = ["a": 1, "b": 2, "c": 3] + /// let b: TreeDictionary = ["b": 4, "d": 5, "e": 6] /// let c = a.keys.subtracting(b.keys) /// // `c` is some permutation of `["a", "c"]` /// @@ -255,19 +255,19 @@ extension ShareableDictionary.Keys { /// hash tree structure to minimize work when possible, e.g. by linking /// parts of the input trees directly into the result. public func subtracting( - _ other: ShareableDictionary.Keys + _ other: TreeDictionary.Keys ) -> Self { guard let r = _base._root.subtracting(.top, other._base._root) else { return self } - return ShareableDictionary(_new: r).keys + return TreeDictionary(_new: r).keys } /// Returns a new keys view containing the elements of `self` that do not /// occur in the provided persistent set. /// - /// var a: ShareableDictionary = ["a": 1, "b": 2, "c": 3] - /// let b: ShareableSet = ["b", "d", "e"] + /// var a: TreeDictionary = ["a": 1, "b": 2, "c": 3] + /// let b: TreeSet = ["b", "d", "e"] /// let c = a.keys.subtracting(b) /// // `c` is some permutation of `["a", "c"]` /// @@ -278,10 +278,10 @@ extension ShareableDictionary.Keys { /// However, the implementation is careful to make the best use of /// hash tree structure to minimize work when possible, e.g. by linking /// parts of the input trees directly into the result. - public func subtracting(_ other: ShareableSet) -> Self { + public func subtracting(_ other: TreeSet) -> Self { guard let r = _base._root.subtracting(.top, other._root) else { return self } - return ShareableDictionary(_new: r).keys + return TreeDictionary(_new: r).keys } } diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+MapValues.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+MapValues.swift similarity index 87% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+MapValues.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+MapValues.swift index 7b74cd4c..abb8aa76 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+MapValues.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+MapValues.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary { +extension TreeDictionary { /// Returns a new dictionary containing the keys of this dictionary with the /// values transformed by the given closure. /// @@ -23,9 +23,9 @@ extension ShareableDictionary { @inlinable public func mapValues( _ transform: (Value) throws -> T - ) rethrows -> ShareableDictionary { + ) rethrows -> TreeDictionary { let transformed = try _root.mapValues { try transform($0.value) } - return ShareableDictionary(_new: transformed) + return TreeDictionary(_new: transformed) } /// Returns a new dictionary containing only the key-value pairs that have @@ -38,7 +38,7 @@ extension ShareableDictionary { /// and `compactMapValues` with a transformation that returns an optional /// `Int` value. /// - /// let data: ShareableDictionary = ["a": "1", "b": "three", "c": "///4///"] + /// let data: TreeDictionary = ["a": "1", "b": "three", "c": "///4///"] /// /// let m: [String: Int?] = data.mapValues { str in Int(str) } /// // ["a": Optional(1), "b": nil, "c": nil] @@ -57,8 +57,8 @@ extension ShareableDictionary { @inlinable public func compactMapValues( _ transform: (Value) throws -> T? - ) rethrows -> ShareableDictionary { + ) rethrows -> TreeDictionary { let result = try _root.compactMapValues(.top, transform) - return ShareableDictionary(_new: result.finalize(.top)) + return TreeDictionary(_new: result.finalize(.top)) } } diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Merge.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Merge.swift similarity index 97% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Merge.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Merge.swift index ace32cbb..b3cf7d44 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Merge.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Merge.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary { +extension TreeDictionary { /// Merges the key-value pairs in the given sequence into the dictionary, /// using a combining closure to determine the value for any duplicate keys. /// @@ -22,7 +22,7 @@ extension ShareableDictionary { /// This example shows how to choose the current or new values for any /// duplicate keys: /// - /// var dictionary: ShareableDictionary = ["a": 1, "b": 2] + /// var dictionary: TreeDictionary = ["a": 1, "b": 2] /// /// // Keeping existing value for key "a": /// dictionary.merge(zip(["a", "c"], [3, 4])) { (current, _) in current } @@ -58,7 +58,7 @@ extension ShareableDictionary { /// This example shows how to choose the current or new values for any /// duplicate keys: /// - /// var dictionary: ShareableDictionary = ["a": 1, "b": 2] + /// var dictionary: TreeDictionary = ["a": 1, "b": 2] /// /// // Keeping existing value for key "a": /// dictionary.merge(zip(["a", "c"], [3, 4])) { (current, _) in current } @@ -101,7 +101,7 @@ extension ShareableDictionary { /// This example shows how to choose the current or new values for any /// duplicate keys: /// - /// var dictionary: ShareableDictionary = ["a": 1, "b": 2] + /// var dictionary: TreeDictionary = ["a": 1, "b": 2] /// /// // Keeping existing value for key "a": /// dictionary.merge(zip(["a", "c"], [3, 4])) { (current, _) in current } diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Sendable.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Sendable.swift similarity index 90% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Sendable.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Sendable.swift index 00e56919..01bdf115 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Sendable.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Sendable.swift @@ -10,6 +10,6 @@ //===----------------------------------------------------------------------===// #if swift(>=5.5) -extension ShareableDictionary: @unchecked Sendable +extension TreeDictionary: @unchecked Sendable where Key: Sendable, Value: Sendable {} #endif diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Sequence.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Sequence.swift similarity index 93% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Sequence.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Sequence.swift index c03469cc..b3ef68b1 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Sequence.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Sequence.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableDictionary: Sequence { +extension TreeDictionary: Sequence { /// The element type of a dictionary: a tuple containing an individual /// key-value pair. public typealias Element = (key: Key, value: Value) @@ -52,11 +52,11 @@ extension ShareableDictionary: Sequence { } #if swift(>=5.5) -extension ShareableDictionary.Iterator: @unchecked Sendable +extension TreeDictionary.Iterator: @unchecked Sendable where Key: Sendable, Value: Sendable {} #endif -extension ShareableDictionary.Iterator: IteratorProtocol { +extension TreeDictionary.Iterator: IteratorProtocol { /// The element type of a dictionary: a tuple containing an individual /// key-value pair. public typealias Element = (key: Key, value: Value) diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Values.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Values.swift similarity index 80% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Values.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Values.swift index b48ef468..cb0c6a3b 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary+Values.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary+Values.swift @@ -11,21 +11,21 @@ import _CollectionsUtilities -extension ShareableDictionary { +extension TreeDictionary { /// A view of a dictionary’s values. @frozen public struct Values { @usableFromInline - internal typealias _Node = ShareableHashedCollections._Node + internal typealias _Node = HashTreeCollections._Node @usableFromInline internal typealias _UnsafeHandle = _Node.UnsafeHandle @usableFromInline - internal var _base: ShareableDictionary + internal var _base: TreeDictionary @inlinable - internal init(_base: ShareableDictionary) { + internal init(_base: TreeDictionary) { self._base = _base } } @@ -42,28 +42,28 @@ extension ShareableDictionary { } #if swift(>=5.5) -extension ShareableDictionary.Values: Sendable +extension TreeDictionary.Values: Sendable where Key: Sendable, Value: Sendable {} #endif -extension ShareableDictionary.Values: CustomStringConvertible { +extension TreeDictionary.Values: CustomStringConvertible { // A textual representation of this instance. public var description: String { _arrayDescription(for: self) } } -extension ShareableDictionary.Values: CustomDebugStringConvertible { +extension TreeDictionary.Values: CustomDebugStringConvertible { /// A textual representation of this instance, suitable for debugging. public var debugDescription: String { _arrayDescription( for: self, debug: true, - typeName: "\(ShareableDictionary._debugTypeName()).Values") + typeName: "\(TreeDictionary._debugTypeName()).Values") } } -extension ShareableDictionary.Values: Sequence { +extension TreeDictionary.Values: Sequence { public typealias Element = Value @frozen @@ -71,10 +71,10 @@ extension ShareableDictionary.Values: Sequence { public typealias Element = Value @usableFromInline - internal var _base: ShareableDictionary.Iterator + internal var _base: TreeDictionary.Iterator @inlinable - internal init(_base: ShareableDictionary.Iterator) { + internal init(_base: TreeDictionary.Iterator) { self._base = _base } @@ -91,14 +91,14 @@ extension ShareableDictionary.Values: Sequence { } #if swift(>=5.5) -extension ShareableDictionary.Values.Iterator: Sendable +extension TreeDictionary.Values.Iterator: Sendable where Key: Sendable, Value: Sendable {} #endif // Note: This cannot be a MutableCollection because its subscript setter // needs to invalidate indices. -extension ShareableDictionary.Values: Collection { - public typealias Index = ShareableDictionary.Index +extension TreeDictionary.Values: Collection { + public typealias Index = TreeDictionary.Index @inlinable public var isEmpty: Bool { _base.isEmpty } @@ -152,10 +152,10 @@ extension ShareableDictionary.Values: Collection { } #if false -extension ShareableDictionary.Values: BidirectionalCollection { +extension TreeDictionary.Values: BidirectionalCollection { // Note: Let's not do this. `BidirectionalCollection` would imply that // the ordering of elements would be meaningful, which isn't true for - // `ShareableDictionary.Values`. + // `TreeDictionary.Values`. @inlinable public func formIndex(before i: inout Index) { _base.formIndex(before: &i) diff --git a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary.swift b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary.swift similarity index 94% rename from Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary.swift rename to Sources/HashTreeCollections/TreeDictionary/TreeDictionary.swift index cb157b0e..7b4c5611 100644 --- a/Sources/ShareableHashedCollections/ShareableDictionary/ShareableDictionary.swift +++ b/Sources/HashTreeCollections/TreeDictionary/TreeDictionary.swift @@ -13,24 +13,25 @@ /// mutating shared copies and comparing different snapshots of the same /// collection. /// -/// `ShareableDictionary` has the same functionality as a standard +/// `TreeDictionary` has the same functionality as a standard /// `Dictionary`, and it largely implements the same APIs: both are hashed /// collection types with convenient and efficient ways to look up the value /// associated with a particular key, and both types are unordered, meaning that /// neither type provides any guarantees about the ordering of their items. /// -/// However, `ShareableDictionary` is optimizing specifically for use cases +/// However, `TreeDictionary` is optimizing specifically for use cases /// that need to mutate shared copies or to compare a dictionary value to one of -/// its older snapshots. +/// its older snapshots. To use a term from functional programming, +/// `TreeDictionary` implements a _persistent data structure_. /// /// The standard `Dictionary` stores its members in a single, flat hash table, /// and it implements value semantics with all-or-nothing copy-on-write /// behavior: every time a shared copy of a dictionary is mutated, the mutation /// needs to make a full copy of the dictionary's storage. -/// `ShareableDictionary` takes a different approach: it organizes its members +/// `TreeDictionary` takes a different approach: it organizes its members /// into a tree structure, the nodes of which can be freely shared across /// collection values. When mutating a shared copy of a dictionary value, -/// `ShareableDictionary` is able to simply link the unchanged parts of the +/// `TreeDictionary` is able to simply link the unchanged parts of the /// tree directly into the result, saving both time and memory. /// /// This structural sharing also makes it more efficient to compare mutated @@ -39,7 +40,7 @@ /// typically be handled in constant time, leading to a dramatic performance /// boost when the two inputs are still largely unchanged: /// -/// var d = ShareableDictionary( +/// var d = TreeDictionary( /// uniqueKeysWithValues: (0 ..< 10_000).map { ($0, 2 * $0) }) /// let copy = d /// d[20_000] = 42 // Expected to be an O(log(n)) operation @@ -47,7 +48,7 @@ /// // `diff` now holds the single item 20_000. /// /// The tree structure also eliminates the need to reserve capacity in advance: -/// `ShareableDictionary` creates, destroys and resizes individual nodes as +/// `TreeDictionary` creates, destroys and resizes individual nodes as /// needed, always consuming just enough memory to store its contents. As of /// Swift 5.7, the standard collection types never shrink their storage, so /// temporary storage spikes can linger as unused but still allocated memory @@ -55,16 +56,16 @@ /// /// Of course, switching to a tree structure comes with some trade offs. In /// particular, inserting new items, removing existing ones, and iterating over -/// a `ShareableDictionary` is expected to be a constant factor slower than a +/// a `TreeDictionary` is expected to be a constant factor slower than a /// standard `Dictionary` -- allocating/deallocating nodes isn't free, and /// navigating the tree structure requires more pointer dereferences than /// accessing a flat hash table. However the algorithmic improvements above /// usually more than make up for this, as long as the use case can make use of /// them. @frozen // Not really -- this package is not at all ABI stable -public struct ShareableDictionary { +public struct TreeDictionary { @usableFromInline - internal typealias _Node = ShareableHashedCollections._Node + internal typealias _Node = HashTreeCollections._Node @usableFromInline internal typealias _UnsafeHandle = _Node.UnsafeHandle @@ -90,7 +91,7 @@ public struct ShareableDictionary { } } -extension ShareableDictionary { +extension TreeDictionary { /// Accesses the value associated with the given key for reading and writing. /// /// This *key-based* subscript returns the value for the given key if the key @@ -100,7 +101,7 @@ extension ShareableDictionary { /// key found in the dictionary (`"Coral"`) and a key not found in the /// dictionary (`"Cerise"`). /// - /// var hues: ShareableDictionary = ["Heliotrope": 296, "Coral": 16, "Aquamarine": 156] + /// var hues: TreeDictionary = ["Heliotrope": 296, "Coral": 16, "Aquamarine": 156] /// print(hues["Coral"]) /// // Prints "Optional(16)" /// print(hues["Cerise"]) @@ -186,7 +187,7 @@ extension ShareableDictionary { /// example uses the subscript with a message to use in case an HTTP response /// code isn't recognized: /// - /// var responseMessages: ShareableDictionary = [ + /// var responseMessages: TreeDictionary = [ /// 200: "OK", /// 403: "Access forbidden", /// 404: "File not found", @@ -207,7 +208,7 @@ extension ShareableDictionary { /// of each letter in a string: /// /// let message = "Hello, Elle!" - /// var letterCounts: ShareableDictionary = [:] + /// var letterCounts: TreeDictionary = [:] /// for letter in message { /// letterCounts[letter, default: 0] += 1 /// } @@ -298,7 +299,7 @@ extension ShareableDictionary { /// value of an existing key is updated, `updateValue(_:forKey:)` returns /// the original value. /// - /// var hues: ShareableDictionary = [ + /// var hues: TreeDictionary = [ /// "Heliotrope": 296, /// "Coral": 16, /// "Aquamarine": 156] @@ -383,7 +384,7 @@ extension ShareableDictionary { /// in a string: /// /// let message = "Hello, Elle!" - /// var letterCounts: ShareableDictionary = [:] + /// var letterCounts: TreeDictionary = [:] /// for letter in message { /// letterCounts.updateValue(forKey: letter) { count in /// if count == nil { @@ -434,7 +435,7 @@ extension ShareableDictionary { /// in a string: /// /// let message = "Hello, Elle!" - /// var letterCounts: ShareableDictionary = [:] + /// var letterCounts: TreeDictionary = [:] /// for letter in message { /// letterCounts.updateValue(forKey: letter, default: 0) { count in /// count += 1 @@ -483,7 +484,7 @@ extension ShareableDictionary { /// If the key is found in the dictionary, this method returns the key's /// associated value, and invalidates all previously returned indices. /// - /// var hues: ShareableDictionary = [ + /// var hues: TreeDictionary = [ /// "Heliotrope": 296, /// "Coral": 16, /// "Aquamarine": 156] diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Codable.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Codable.swift similarity index 92% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Codable.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Codable.swift index 5e7d8282..fbc81f2b 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Codable.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Codable.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet: Encodable where Element: Encodable { +extension TreeSet: Encodable where Element: Encodable { /// Encodes the elements of this set into the given encoder. /// /// - Parameter encoder: The encoder to write data to. @@ -20,7 +20,7 @@ extension ShareableSet: Encodable where Element: Encodable { } } -extension ShareableSet: Decodable where Element: Decodable { +extension TreeSet: Decodable where Element: Decodable { /// Creates a new set by decoding from the given decoder. /// /// This initializer throws an error if reading from the decoder fails, or diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Collection.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Collection.swift similarity index 94% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Collection.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Collection.swift index fa94c290..7817af25 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Collection.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Collection.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// The position of an element in a persistent set. /// /// An index in a persistent set is a compact encoding of a path in the @@ -39,11 +39,11 @@ extension ShareableSet { } #if swift(>=5.5) -extension ShareableSet.Index: @unchecked Sendable +extension TreeSet.Index: @unchecked Sendable where Element: Sendable {} #endif -extension ShareableSet.Index: Equatable { +extension TreeSet.Index: Equatable { /// Returns a Boolean value indicating whether two index values are equal. /// /// Note that comparing two indices that do not belong to the same tree @@ -59,7 +59,7 @@ extension ShareableSet.Index: Equatable { } } -extension ShareableSet.Index: Comparable { +extension TreeSet.Index: Comparable { /// Returns a Boolean value indicating whether the value of the first argument /// is less than the second argument. /// @@ -76,7 +76,7 @@ extension ShareableSet.Index: Comparable { } } -extension ShareableSet.Index: Hashable { +extension TreeSet.Index: Hashable { /// Hashes the essential components of this value by feeding them into the /// given hasher. /// @@ -87,21 +87,21 @@ extension ShareableSet.Index: Hashable { } } -extension ShareableSet.Index: CustomStringConvertible { +extension TreeSet.Index: CustomStringConvertible { // A textual representation of this instance. public var description: String { _path.description } } -extension ShareableSet.Index: CustomDebugStringConvertible { +extension TreeSet.Index: CustomDebugStringConvertible { /// A textual representation of this instance, suitable for debugging. public var debugDescription: String { description } } -extension ShareableSet: Collection { +extension TreeSet: Collection { /// A Boolean value indicating whether the collection is empty. /// /// - Complexity: O(1) @@ -198,7 +198,7 @@ extension ShareableSet: Collection { /// - Parameter start: A valid index of the collection. /// - Parameter end: Another valid index of the collection. /// - Returns: The distance between `start` and `end`. - /// (The result can be negative, even though `ShareableSet` is not a + /// (The result can be negative, even though `TreeSet` is not a /// bidirectional collection.) /// - Complexity: O(log(`count`)) @inlinable @@ -215,7 +215,7 @@ extension ShareableSet: Collection { /// - Parameters: /// - i: A valid index of the collection. /// - distance: The distance to offset `i`. As a special exception, - /// `distance` is allowed to be negative even though `ShareableSet` + /// `distance` is allowed to be negative even though `TreeSet` /// isn't a bidirectional collection. /// - Returns: An index offset by `distance` from the index `i`. If /// `distance` is positive, this is the same value as the result of @@ -243,7 +243,7 @@ extension ShareableSet: Collection { /// - Parameters: /// - i: A valid index of the collection. /// - distance: The distance to offset `i`. As a special exception, - /// `distance` is allowed to be negative even though `ShareableSet` + /// `distance` is allowed to be negative even though `TreeSet` /// isn't a bidirectional collection. /// - limit: A valid index of the collection to use as a limit. If /// `distance > 0`, a limit that is less than `i` has no effect. @@ -340,8 +340,8 @@ extension ShareableSet: Collection { #if false // Note: Let's not do this. `BidirectionalCollection` would imply that // the ordering of elements would be meaningful, which isn't true for -// `ShareableSet`. -extension ShareableSet: BidirectionalCollection { +// `TreeSet`. +extension TreeSet: BidirectionalCollection { /// Replaces the given index with its predecessor. /// /// - Parameter i: A valid index of the collection. diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+CustomReflectable.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+CustomReflectable.swift similarity index 93% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+CustomReflectable.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+CustomReflectable.swift index d6d726d9..1d8f0125 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+CustomReflectable.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+CustomReflectable.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet: CustomReflectable { +extension TreeSet: CustomReflectable { /// The custom mirror for this instance. public var customMirror: Mirror { Mirror(self, unlabeledChildren: self, displayStyle: .set) diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Debugging.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Debugging.swift similarity index 98% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Debugging.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Debugging.swift index 38a6e7c8..14d69fa0 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Debugging.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Debugging.swift @@ -11,7 +11,7 @@ import _CollectionsUtilities -extension ShareableSet { +extension TreeSet { /// True if consistency checking is enabled in the implementation of this /// type, false otherwise. /// diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Descriptions.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Descriptions.swift similarity index 85% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Descriptions.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Descriptions.swift index 2beb7eba..f32127f1 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Descriptions.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Descriptions.swift @@ -11,14 +11,14 @@ import _CollectionsUtilities -extension ShareableSet: CustomStringConvertible { +extension TreeSet: CustomStringConvertible { /// A textual representation of this instance. public var description: String { _arrayDescription(for: self) } } -extension ShareableSet: CustomDebugStringConvertible { +extension TreeSet: CustomDebugStringConvertible { /// A textual representation of this instance, suitable for debugging. public var debugDescription: String { _arrayDescription( @@ -26,6 +26,6 @@ extension ShareableSet: CustomDebugStringConvertible { } internal func _debugTypeName() -> String { - "ShareableSet<\(Element.self)>" + "TreeSet<\(Element.self)>" } } diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Equatable.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Equatable.swift similarity index 96% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Equatable.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Equatable.swift index 418cf98d..af5109f9 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Equatable.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Equatable.swift @@ -11,7 +11,7 @@ import _CollectionsUtilities -extension ShareableSet: Equatable { +extension TreeSet: Equatable { /// Returns a Boolean value indicating whether two values are equal. /// /// Two persistent sets are considered equal if they contain the same diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+ExpressibleByArrayLiteral.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+ExpressibleByArrayLiteral.swift similarity index 96% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+ExpressibleByArrayLiteral.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+ExpressibleByArrayLiteral.swift index d050043f..5f67afad 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+ExpressibleByArrayLiteral.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+ExpressibleByArrayLiteral.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet: ExpressibleByArrayLiteral { +extension TreeSet: ExpressibleByArrayLiteral { /// Creates a new set from the contents of an array literal. /// /// Duplicate elements in the literal are allowed, but the resulting diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Extras.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Extras.swift similarity index 97% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Extras.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Extras.swift index d1ee5076..788187ef 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Extras.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Extras.swift @@ -11,9 +11,9 @@ import _CollectionsUtilities -extension ShareableSet: _UniqueCollection {} +extension TreeSet: _UniqueCollection {} -extension ShareableSet { +extension TreeSet { /// Removes the element at the given valid index. /// /// Calling this method invalidates all existing indices of the collection. diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Filter.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Filter.swift similarity index 93% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Filter.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Filter.swift index 0514e6c0..7c2ce7f5 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Filter.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Filter.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Returns a new persistent set containing all the members of this persistent /// set that satisfy the given predicate. /// @@ -26,7 +26,7 @@ extension ShareableSet { ) rethrows -> Self { let result = try _root.filter(.top) { try isIncluded($0.key) } guard let result = result else { return self } - return ShareableSet(_new: result.finalize(.top)) + return TreeSet(_new: result.finalize(.top)) } /// Removes all the elements that satisfy the given predicate. @@ -36,7 +36,7 @@ extension ShareableSet { /// This example removes all the odd values from a /// set of numbers: /// - /// var numbers: ShareableSet = [5, 6, 7, 8, 9, 10, 11] + /// var numbers: TreeSet = [5, 6, 7, 8, 9, 10, 11] /// numbers.removeAll(where: { $0 % 2 != 0 }) /// // numbers == [6, 8, 10] /// diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Hashable.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Hashable.swift similarity index 95% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Hashable.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Hashable.swift index 481c83f8..07e45612 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Hashable.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Hashable.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet: Hashable { +extension TreeSet: Hashable { /// Hashes the essential components of this value by feeding them into the /// given hasher. /// diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Sendable.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Sendable.swift similarity index 86% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Sendable.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Sendable.swift index e1da09c8..b5b758e2 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Sendable.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Sendable.swift @@ -10,5 +10,5 @@ //===----------------------------------------------------------------------===// #if swift(>=5.5) -extension ShareableSet: @unchecked Sendable where Element: Sendable {} +extension TreeSet: @unchecked Sendable where Element: Sendable {} #endif diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Sequence.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+Sequence.swift similarity index 91% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Sequence.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+Sequence.swift index 447f4662..cd0e3fdf 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+Sequence.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+Sequence.swift @@ -9,8 +9,8 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet: Sequence { - /// An iterator over the members of a `ShareableSet`. +extension TreeSet: Sequence { + /// An iterator over the members of a `TreeSet`. @frozen public struct Iterator: IteratorProtocol { @usableFromInline @@ -50,6 +50,6 @@ extension ShareableSet: Sequence { } #if swift(>=5.5) -extension ShareableSet.Iterator: @unchecked Sendable +extension TreeSet.Iterator: @unchecked Sendable where Element: Sendable {} #endif diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra Initializers.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra Initializers.swift similarity index 96% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra Initializers.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra Initializers.swift index 6ff84625..b6147665 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra Initializers.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra Initializers.swift @@ -9,7 +9,7 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Creates an empty set. /// /// This initializer is equivalent to initializing with an empty array @@ -62,7 +62,7 @@ extension ShareableSet { /// - Complexity: O(*items.count*) @inlinable public init( - _ item: __owned ShareableDictionary.Keys + _ item: __owned TreeDictionary.Keys ) { self.init(_new: item._base._root.mapValues { _ in () }) } diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra basics.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra basics.swift similarity index 99% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra basics.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra basics.swift index da4b3376..da97d142 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra basics.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra basics.swift @@ -11,7 +11,7 @@ import _CollectionsUtilities -extension ShareableSet: SetAlgebra { +extension TreeSet: SetAlgebra { /// Returns a Boolean value that indicates whether the given element exists /// in the set. /// diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formIntersection.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formIntersection.swift similarity index 93% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formIntersection.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formIntersection.swift index 94636a68..217930fe 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formIntersection.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formIntersection.swift @@ -9,11 +9,11 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Removes the elements of this set that aren't also in the given one. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [0, 2, 4, 6] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [0, 2, 4, 6] /// a.formIntersection(b) /// // `a` is now some permutation of `[2, 4]` /// @@ -50,7 +50,7 @@ extension ShareableSet { /// parts of the input trees directly into the result. @inlinable public mutating func formIntersection( - _ other: ShareableDictionary.Keys + _ other: TreeDictionary.Keys ) { // FIXME: Implement in-place reductions self = intersection(other) @@ -58,7 +58,7 @@ extension ShareableSet { /// Removes the elements of this set that aren't also in the given sequence. /// - /// var a: ShareableSet = [1, 2, 3, 4] + /// var a: TreeSet = [1, 2, 3, 4] /// let b = [0, 2, 4, 6] /// a.formIntersection(b) /// // `a` is now some permutation of `[2, 4]` diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formSymmetricDifference.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formSymmetricDifference.swift similarity index 88% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formSymmetricDifference.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formSymmetricDifference.swift index c8c2fc54..2bbf5690 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formSymmetricDifference.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formSymmetricDifference.swift @@ -9,12 +9,12 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Replace this set with the elements contained in this set or the given /// set, but not both. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [0, 2, 4, 6] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [0, 2, 4, 6] /// a.formSymmetricDifference(b) /// // `a` is now some permutation of `[0, 1, 3, 6]` /// @@ -33,8 +33,8 @@ extension ShareableSet { /// Replace this set with the elements contained in this set or the given /// keys view of a persistent dictionary, but not both. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] /// a.formSymmetricDifference(b.keys) /// // `a` is now some permutation of `[0, 1, 3, 6]` /// @@ -47,7 +47,7 @@ extension ShareableSet { /// parts of the input trees directly into the result. @inlinable public mutating func formSymmetricDifference( - _ other: __owned ShareableDictionary.Keys + _ other: __owned TreeDictionary.Keys ) { self = symmetricDifference(other) } @@ -55,7 +55,7 @@ extension ShareableSet { /// Replace this set with the elements contained in this set or the given /// sequence, but not both. /// - /// var a: ShareableSet = [1, 2, 3, 4] + /// var a: TreeSet = [1, 2, 3, 4] /// let b = [0, 2, 4, 6, 2, 4, 6] /// a.formSymmetricDifference(b) /// // `a` is now some permutation of `[0, 1, 3, 6]` diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formUnion.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formUnion.swift similarity index 91% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formUnion.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formUnion.swift index bebf0c7c..0e39424f 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra formUnion.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra formUnion.swift @@ -9,11 +9,11 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Adds the elements of the given set to this set. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [0, 2, 4, 6] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [0, 2, 4, 6] /// a.formUnion(b) /// // `a` is now some permutation of `[0, 1, 2, 3, 4, 6]` /// @@ -37,8 +37,8 @@ extension ShareableSet { /// Adds the elements of the given keys view of a persistent dictionary /// to this set. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] /// a.formUnion(b.keys) /// // `a` is now some permutation of `[0, 1, 2, 3, 4, 6]` /// @@ -56,14 +56,14 @@ extension ShareableSet { /// parts of the input trees directly into the result. @inlinable public mutating func formUnion( - _ other: __owned ShareableDictionary.Keys + _ other: __owned TreeDictionary.Keys ) { self = union(other) } /// Adds the elements of the given sequence to this set. /// - /// var a: ShareableSet = [1, 2, 3, 4] + /// var a: TreeSet = [1, 2, 3, 4] /// let b = [0, 2, 4, 6, 0, 2] /// a.formUnion(b) /// // `a` is now some permutation of `[0, 1, 2, 3, 4, 6]` diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra intersection.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra intersection.swift similarity index 90% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra intersection.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra intersection.swift index 8db89140..f90000f9 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra intersection.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra intersection.swift @@ -9,12 +9,12 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Returns a new set with the elements that are common to both this set and /// the provided other one. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [0, 2, 4, 6] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [0, 2, 4, 6] /// let c = a.intersection(b) /// // `c` is some permutation of `[2, 4]` /// @@ -37,8 +37,8 @@ extension ShareableSet { /// Returns a new set with the elements that are common to both this set and /// the provided keys view of a persistent dictionary. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] /// let c = a.intersection(b.keys) /// // `c` is some permutation of `[2, 4]` /// @@ -55,14 +55,14 @@ extension ShareableSet { /// parts of the input trees directly into the result. @inlinable @inline(__always) public func intersection( - _ other: ShareableDictionary.Keys + _ other: TreeDictionary.Keys ) -> Self { _intersection(other._base._root) } @inlinable internal func _intersection( - _ other: ShareableHashedCollections._Node + _ other: HashTreeCollections._Node ) -> Self { guard let r = _root.intersection(.top, other) else { return self } return Self(_new: r) @@ -71,7 +71,7 @@ extension ShareableSet { /// Returns a new set with the elements that are common to both this set and /// the provided sequence. /// - /// var a: ShareableSet = [1, 2, 3, 4] + /// var a: TreeSet = [1, 2, 3, 4] /// let b = [0, 2, 4, 6] /// let c = a.intersection(b) /// // `c` is some permutation of `[2, 4]` diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isDisjoint.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isDisjoint.swift similarity index 87% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isDisjoint.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isDisjoint.swift index dad58572..09872594 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isDisjoint.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isDisjoint.swift @@ -9,12 +9,12 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Returns a Boolean value that indicates whether the set has no members in /// common with the given set. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [5, 6] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [5, 6] /// a.isDisjoint(with: b) // true /// /// - Parameter other: Another set. @@ -32,8 +32,8 @@ extension ShareableSet { /// Returns a Boolean value that indicates whether the set has no members in /// common with the given set. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [5, 6] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [5, 6] /// a.isDisjoint(with: b) // true /// /// - Parameter other: The keys view of a persistent dictionary. @@ -45,7 +45,7 @@ extension ShareableSet { /// average, if `Element` implements high-quality hashing. @inlinable public func isDisjoint( - with other: ShareableDictionary.Keys + with other: TreeDictionary.Keys ) -> Bool { self._root.isDisjoint(.top, with: other._base._root) } @@ -53,8 +53,8 @@ extension ShareableSet { /// Returns a Boolean value that indicates whether the set has no members in /// common with the given set. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [5, 6] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [5, 6] /// a.isDisjoint(with: b) // true /// /// - Parameter other: A finite sequence of elements, some of which may diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isEqualSet.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isEqualSet.swift similarity index 97% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isEqualSet.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isEqualSet.swift index 6bd1c2e2..50876252 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isEqualSet.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isEqualSet.swift @@ -12,7 +12,7 @@ import _CollectionsUtilities // FIXME: These are non-standard extensions generalizing ==. -extension ShareableSet { +extension TreeSet { /// Returns a Boolean value indicating whether persistent sets are equal. Two /// persistent sets are considered equal if they contain the same elements, /// but not necessarily in the same order. @@ -46,7 +46,7 @@ extension ShareableSet { /// comparing elements in shared subtrees. @inlinable public func isEqualSet( - to other: ShareableDictionary.Keys + to other: TreeDictionary.Keys ) -> Bool { _root.isEqualSet(to: other._base._root, by: { _, _ in true }) } @@ -58,7 +58,7 @@ extension ShareableSet { /// Duplicate items in `other` do not prevent it from comparing equal to /// `self`. /// - /// let this: ShareableSet = [0, 1, 5, 6] + /// let this: TreeSet = [0, 1, 5, 6] /// let that = [5, 5, 0, 1, 1, 6, 5, 0, 1, 6, 6, 5] /// /// this.isEqualSet(to: that) // true diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isStrictSubset.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isStrictSubset.swift similarity index 93% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isStrictSubset.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isStrictSubset.swift index ef71df7d..be71ea6b 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isStrictSubset.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isStrictSubset.swift @@ -11,7 +11,7 @@ import _CollectionsUtilities -extension ShareableSet { +extension TreeSet { /// Returns a Boolean value that indicates whether the set is a strict subset /// of the given set. /// @@ -19,8 +19,8 @@ extension ShareableSet { /// also a member of *B* and *B* contains at least one element that is not a /// member of *A*. (Ignoring the order the elements appear in the sets.) /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// b.isStrictSubset(of: a) // true /// /// - Parameter other: Another set. @@ -45,8 +45,8 @@ extension ShareableSet { /// also a member of *B* and *B* contains at least one element that is not a /// member of *A*. (Ignoring the order the elements appear in the sets.) /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// b.isStrictSubset(of: a) // true /// /// - Parameter other: The keys view of a persistent dictionary. @@ -60,7 +60,7 @@ extension ShareableSet { /// e.g. by skipping over parts of the input trees. @inlinable public func isStrictSubset( - of other: ShareableDictionary.Keys + of other: TreeDictionary.Keys ) -> Bool { guard self.count < other.count else { return false } return isSubset(of: other) @@ -73,8 +73,8 @@ extension ShareableSet { /// also a member of *B* and *B* contains at least one element that is not a /// member of *A*. (Ignoring the order the elements appear in the sets.) /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// b.isStrictSubset(of: a) // true /// /// - Parameter other: A sequence of elements, some of whose elements may diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isStrictSuperset.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isStrictSuperset.swift similarity index 93% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isStrictSuperset.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isStrictSuperset.swift index 84497997..8a1633ca 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isStrictSuperset.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isStrictSuperset.swift @@ -11,7 +11,7 @@ import _CollectionsUtilities -extension ShareableSet { +extension TreeSet { /// Returns a Boolean value that indicates whether the set is a strict /// superset of the given set. /// @@ -19,8 +19,8 @@ extension ShareableSet { /// also a member of *A* and *A* contains at least one element that is *not* /// a member of *B*. (Ignoring the order the elements appear in the sets.) /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// a.isStrictSuperset(of: b.unordered) // true /// /// - Parameter other: Another set. @@ -45,8 +45,8 @@ extension ShareableSet { /// also a member of *B* and *B* contains at least one element that is not a /// member of *A*. (Ignoring the order the elements appear in the sets.) /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// a.isStrictSuperset(of: b.unordered) // true /// /// - Parameter other: The keys view of a persistent dictionary. @@ -60,7 +60,7 @@ extension ShareableSet { /// e.g. by skipping over parts of the input trees. @inlinable public func isStrictSuperset( - of other: ShareableDictionary.Keys + of other: TreeDictionary.Keys ) -> Bool { guard self.count > other.count else { return false } return other._base._root.isSubset(.top, of: self._root) @@ -73,8 +73,8 @@ extension ShareableSet { /// also a member of *B* and *B* contains at least one element that is not a /// member of *A*. (Ignoring the order the elements appear in the sets.) /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// a.isStrictSuperset(of: b.unordered) // true /// /// - Parameter other: A sequence of elements, some of whose elements may diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isSubset.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isSubset.swift similarity index 91% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isSubset.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isSubset.swift index e9e96618..fb0d216b 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isSubset.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isSubset.swift @@ -11,15 +11,15 @@ import _CollectionsUtilities -extension ShareableSet { +extension TreeSet { /// Returns a Boolean value that indicates whether this set is a subset of /// the given set. /// /// Set *A* is a subset of another set *B* if every member of *A* is also a /// member of *B*, ignoring the order they appear in the two sets. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// b.isSubset(of: a) // true /// /// - Parameter other: Another set. @@ -41,8 +41,8 @@ extension ShareableSet { /// Set *A* is a subset of another set *B* if every member of *A* is also a /// member of *B*, ignoring the order they appear in the two sets. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// b.isSubset(of: a) // true /// /// - Parameter other: The keys view of a persistent dictionary. @@ -55,7 +55,7 @@ extension ShareableSet { /// e.g. by skipping over parts of the input trees. @inlinable public func isSubset( - of other: ShareableDictionary.Keys + of other: TreeDictionary.Keys ) -> Bool { self._root.isSubset(.top, of: other._base._root) } @@ -66,8 +66,8 @@ extension ShareableSet { /// Set *A* is a subset of another set *B* if every member of *A* is also a /// member of *B*, ignoring the order they appear in the two sets. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// b.isSubset(of: a) // true /// /// - Parameter other: A sequence of elements, some of whose elements may diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isSuperset.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isSuperset.swift similarity index 89% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isSuperset.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isSuperset.swift index c5608480..b350dcd9 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra isSuperset.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra isSuperset.swift @@ -9,15 +9,15 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Returns a Boolean value that indicates whether this set is a superset of /// the given set. /// /// Set *A* is a superset of another set *B* if every member of *B* is also a /// member of *A*, ignoring the order they appear in the two sets. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// a.isSuperset(of: b) // true /// /// - Parameter other: Another set. @@ -39,8 +39,8 @@ extension ShareableSet { /// Set *A* is a superset of another set *B* if every member of *B* is also a /// member of *A*, ignoring the order they appear in the two sets. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// a.isSuperset(of: b) // true /// /// - Parameter other: The keys view of a persistent dictionary. @@ -53,7 +53,7 @@ extension ShareableSet { /// e.g. by skipping over parts of the input trees. @inlinable public func isSuperset( - of other: ShareableDictionary.Keys + of other: TreeDictionary.Keys ) -> Bool { other._base._root.isSubset(.top, of: self._root) } @@ -64,8 +64,8 @@ extension ShareableSet { /// Set *A* is a superset of another set *B* if every member of *B* is also a /// member of *A*, ignoring the order they appear in the two sets. /// - /// let a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [4, 2, 1] + /// let a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [4, 2, 1] /// a.isSuperset(of: b) // true /// /// - Parameter other: A sequence of elements, some of whose elements may diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra subtract.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra subtract.swift similarity index 87% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra subtract.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra subtract.swift index 0f432665..94a4d48f 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra subtract.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra subtract.swift @@ -9,11 +9,11 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Removes the elements of the given set from this set. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [0, 2, 4, 6] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [0, 2, 4, 6] /// a.subtract(b) /// // `a` is now some permutation of `[1, 3]` /// @@ -33,8 +33,8 @@ extension ShareableSet { /// Removes the elements of the given keys view of a persistent dictionary /// from this set. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] /// a.subtract(b.keys) /// // `a` is now some permutation of `[1, 3]` /// @@ -47,7 +47,7 @@ extension ShareableSet { /// parts of the input trees directly into the result. @inlinable public mutating func subtract( - _ other: ShareableDictionary.Keys + _ other: TreeDictionary.Keys ) { // FIXME: Implement in-place reductions self = subtracting(other) @@ -55,7 +55,7 @@ extension ShareableSet { /// Removes the elements of the given sequence from this set. /// - /// var a: ShareableSet = [1, 2, 3, 4] + /// var a: TreeSet = [1, 2, 3, 4] /// let b = [0, 2, 4, 6] /// a.subtract(b) /// // `a` is now some permutation of `[1, 3]` diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra subtracting.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra subtracting.swift similarity index 89% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra subtracting.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra subtracting.swift index 5eab5660..78fba0d0 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra subtracting.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra subtracting.swift @@ -9,12 +9,12 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Returns a new set containing the elements of this set that do not occur /// in the given other set. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [0, 2, 4, 6] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [0, 2, 4, 6] /// let c = a.subtracting(b) /// // `c` is some permutation of `[1, 3]` /// @@ -33,8 +33,8 @@ extension ShareableSet { /// Returns a new set containing the elements of this set that do not occur /// in the given keys view of a persistent dictionary. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] /// let c = a.subtracting(b.keys) /// // `c` is some permutation of `[1, 3]` /// @@ -47,14 +47,14 @@ extension ShareableSet { /// parts of the input trees directly into the result. @inlinable public __consuming func subtracting( - _ other: ShareableDictionary.Keys + _ other: TreeDictionary.Keys ) -> Self { _subtracting(other._base._root) } @inlinable internal __consuming func _subtracting( - _ other: ShareableHashedCollections._Node + _ other: HashTreeCollections._Node ) -> Self { guard let r = _root.subtracting(.top, other) else { return self } return Self(_new: r) @@ -63,7 +63,7 @@ extension ShareableSet { /// Returns a new set containing the elements of this set that do not occur /// in the given sequence. /// - /// var a: ShareableSet = [1, 2, 3, 4] + /// var a: TreeSet = [1, 2, 3, 4] /// let b = [0, 2, 4, 6] /// let c = a.subtracting(b) /// // `c` is some permutation of `[1, 3]` diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra symmetricDifference.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra symmetricDifference.swift similarity index 89% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra symmetricDifference.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra symmetricDifference.swift index 5c4fff76..9d68d781 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra symmetricDifference.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra symmetricDifference.swift @@ -11,12 +11,12 @@ import _CollectionsUtilities -extension ShareableSet { +extension TreeSet { /// Returns a new set with the elements that are either in this set or in /// `other`, but not in both. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [0, 2, 4, 6] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [0, 2, 4, 6] /// let c = a.symmetricDifference(b) /// // `c` is some permutation of `[0, 1, 3, 6]` /// @@ -33,14 +33,14 @@ extension ShareableSet { guard let branch = branch else { return self } let root = branch.finalize(.top) root._fullInvariantCheck() - return ShareableSet(_new: root) + return TreeSet(_new: root) } /// Returns a new set with the elements that are either in this set or in /// `other`, but not in both. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] /// let c = a.symmetricDifference(b.keys) /// // `c` is some permutation of `[0, 1, 3, 6]` /// @@ -53,19 +53,19 @@ extension ShareableSet { /// parts of the input trees directly into the result. @inlinable public func symmetricDifference( - _ other: __owned ShareableDictionary.Keys + _ other: __owned TreeDictionary.Keys ) -> Self { let branch = _root.symmetricDifference(.top, other._base._root) guard let branch = branch else { return self } let root = branch.finalize(.top) root._fullInvariantCheck() - return ShareableSet(_new: root) + return TreeSet(_new: root) } /// Returns a new set with the elements that are either in this set or in /// the given sequence, but not in both. /// - /// var a: ShareableSet = [1, 2, 3, 4] + /// var a: TreeSet = [1, 2, 3, 4] /// let b = [0, 2, 4, 6, 6, 2] /// let c = a.symmetricDifference(b) /// // `c` is some permutation of `[0, 1, 3, 6]` @@ -106,7 +106,7 @@ extension ShareableSet { // If `other` may contain duplicates, we need to be more // careful (and slower). - let other = ShareableSet(other) + let other = TreeSet(other) return self.symmetricDifference(other) } } diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra union.swift b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra union.swift similarity index 90% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra union.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra union.swift index 615599d2..2cdcad76 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet+SetAlgebra union.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet+SetAlgebra union.swift @@ -9,11 +9,11 @@ // //===----------------------------------------------------------------------===// -extension ShareableSet { +extension TreeSet { /// Returns a new set with the elements of both this and the given set. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableSet = [0, 2, 4, 6] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeSet = [0, 2, 4, 6] /// let c = a.union(b) /// // `c` is some permutation of `[0, 1, 2, 3, 4, 6]` /// @@ -34,14 +34,14 @@ extension ShareableSet { let r = _root.union(.top, other._root) guard r.copied else { return self } r.node._fullInvariantCheck() - return ShareableSet(_new: r.node) + return TreeSet(_new: r.node) } /// Returns a new set with the elements of both this set and the given /// keys view of a persistent dictionary. /// - /// var a: ShareableSet = [1, 2, 3, 4] - /// let b: ShareableDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] + /// var a: TreeSet = [1, 2, 3, 4] + /// let b: TreeDictionary = [0: "a", 2: "b", 4: "c", 6: "d"] /// let c = a.union(b) /// // `c` is some permutation of `[0, 1, 2, 3, 4, 6]` /// @@ -59,18 +59,18 @@ extension ShareableSet { /// parts of the input trees directly into the result. @inlinable public func union( - _ other: __owned ShareableDictionary.Keys + _ other: __owned TreeDictionary.Keys ) -> Self { let r = _root.union(.top, other._base._root) guard r.copied else { return self } r.node._fullInvariantCheck() - return ShareableSet(_new: r.node) + return TreeSet(_new: r.node) } /// Returns a new set with the elements of both this set and the given /// sequence. /// - /// var a: ShareableSet = [1, 2, 3, 4] + /// var a: TreeSet = [1, 2, 3, 4] /// let b = [0, 2, 4, 6, 0, 2] /// let c = a.union(b) /// // `c` is some permutation of `[0, 1, 2, 3, 4, 6]` diff --git a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet.swift b/Sources/HashTreeCollections/TreeSet/TreeSet.swift similarity index 82% rename from Sources/ShareableHashedCollections/ShareableSet/ShareableSet.swift rename to Sources/HashTreeCollections/TreeSet/TreeSet.swift index 05d48859..8ca4c6e4 100644 --- a/Sources/ShareableHashedCollections/ShareableSet/ShareableSet.swift +++ b/Sources/HashTreeCollections/TreeSet/TreeSet.swift @@ -12,22 +12,23 @@ /// An unordered collection of unique elements, optimized for mutating shared /// copies and comparing different snapshots of the same collection. /// -/// `ShareableSet` has the same functionality as a standard `Set`, and +/// `TreeSet` has the same functionality as a standard `Set`, and /// it largely implements the same APIs: both are hashed collection /// types that conform to `SetAlgebra`, and both are unordered -- neither type /// provides any guarantees about the ordering of their members. /// -/// However, `ShareableSet` is optimizing specifically for use cases that +/// However, `TreeSet` is optimizing specifically for use cases that /// need to mutate shared copies or to compare a set value to one of its older -/// snapshots. +/// snapshots. To use a term from functional programming, +/// `TreeSet` implements a _persistent data structure_. /// /// The standard `Set` stores its members in a single, flat hash table, and it /// implements value semantics with all-or-nothing copy-on-write behavior: every /// time a shared copy of a set is mutated, the mutation needs to make a full -/// copy of the set's storage. `ShareableSet` takes a different approach: it +/// copy of the set's storage. `TreeSet` takes a different approach: it /// organizes its members into a tree structure, the nodes of which can be /// freely shared across collection values. When mutating a shared copy of a set -/// value, `ShareableSet` is able to simply link the unchanged parts of the +/// value, `TreeSet` is able to simply link the unchanged parts of the /// tree directly into the result, saving both time and memory. /// /// This structural sharing also makes it more efficient to compare mutated set @@ -36,14 +37,14 @@ /// constant time, leading to a dramatic performance boost when the two inputs /// are still largely unchanged: /// -/// var set = ShareableSet(0 ..< 10_000) +/// var set = TreeSet(0 ..< 10_000) /// let copy = set /// set.insert(20_000) // Expected to be an O(log(n)) operation /// let diff = set.subtracting(copy) // Also O(log(n))! /// // `diff` now holds the single item 20_000. /// /// The tree structure also eliminates the need to reserve capacity in advance: -/// `ShareableSet` creates, destroys and resizes individual nodes as needed, +/// `TreeSet` creates, destroys and resizes individual nodes as needed, /// always consuming just enough memory to store its contents. As of Swift 5.7, /// the standard collection types never shrink their storage, so temporary /// storage spikes can linger as unused but still allocated memory long after @@ -51,15 +52,15 @@ /// /// Of course, switching to a tree structure comes with some trade offs. In /// particular, inserting new items, removing existing ones, and iterating over -/// a `ShareableSet` is expected to be a constant factor slower than a standard +/// a `TreeSet` is expected to be a constant factor slower than a standard /// `Set` -- allocating/deallocating nodes isn't free, and navigating the tree /// structure requires more pointer dereferences than accessing a flat hash /// table. However the algorithmic improvements above usually more than make up /// for this, as long as the use case can make use of them. @frozen // Not really -- this package is not at all ABI stable -public struct ShareableSet { +public struct TreeSet { @usableFromInline - internal typealias _Node = ShareableHashedCollections._Node + internal typealias _Node = HashTreeCollections._Node @usableFromInline internal typealias _UnsafeHandle = _Node.UnsafeHandle diff --git a/Sources/ShareableHashedCollections/CMakeLists.txt b/Sources/ShareableHashedCollections/CMakeLists.txt deleted file mode 100644 index 3ce2da64..00000000 --- a/Sources/ShareableHashedCollections/CMakeLists.txt +++ /dev/null @@ -1,103 +0,0 @@ -#[[ -This source file is part of the Swift Collections Open Source Project - -Copyright (c) 2022 Apple Inc. and the Swift project authors -Licensed under Apache License v2.0 with Runtime Library Exception - -See https://swift.org/LICENSE.txt for license information -#]] - -add_library(ShareableHashedCollections - "Node/_AncestorSlots.swift" - "Node/_Bitmap.swift" - "Node/_Bucket.swift" - "Node/_Hash.swift" - "Node/_HashTreeIterator.swift" - "Node/_HashTreeStatistics.swift" - "Node/_Level.swift" - "Node/_Node+Builder.swift" - "Node/_Node+Debugging.swift" - "Node/_Node+Initializers.swift" - "Node/_Node+Invariants.swift" - "Node/_Node+Lookups.swift" - "Node/_Node+Primitive Insertions.swift" - "Node/_Node+Primitive Removals.swift" - "Node/_Node+Primitive Replacement.swift" - "Node/_Node+Storage.swift" - "Node/_Node+Structural compactMapValues.swift" - "Node/_Node+Structural filter.swift" - "Node/_Node+Structural intersection.swift" - "Node/_Node+Structural isDisjoint.swift" - "Node/_Node+Structural isEqualSet.swift" - "Node/_Node+Structural isSubset.swift" - "Node/_Node+Structural mapValues.swift" - "Node/_Node+Structural merge.swift" - "Node/_Node+Structural subtracting.swift" - "Node/_Node+Structural symmetricDifference.swift" - "Node/_Node+Structural union.swift" - "Node/_Node+Subtree Insertions.swift" - "Node/_Node+Subtree Modify.swift" - "Node/_Node+Subtree Removals.swift" - "Node/_Node+UnsafeHandle.swift" - "Node/_Node.swift" - "Node/_RawNode+UnsafeHandle.swift" - "Node/_RawNode.swift" - "Node/_Slot.swift" - "Node/_Stack.swift" - "Node/_StorageHeader.swift" - "Node/_UnmanagedNode.swift" - "Node/_UnsafePath.swift" - "ShareableDictionary/ShareableDictionary+Codable.swift" - "ShareableDictionary/ShareableDictionary+Collection.swift" - "ShareableDictionary/ShareableDictionary+CustomReflectable.swift" - "ShareableDictionary/ShareableDictionary+Debugging.swift" - "ShareableDictionary/ShareableDictionary+Descriptions.swift" - "ShareableDictionary/ShareableDictionary+Equatable.swift" - "ShareableDictionary/ShareableDictionary+ExpressibleByDictionaryLiteral.swift" - "ShareableDictionary/ShareableDictionary+Filter.swift" - "ShareableDictionary/ShareableDictionary+Hashable.swift" - "ShareableDictionary/ShareableDictionary+Initializers.swift" - "ShareableDictionary/ShareableDictionary+Keys.swift" - "ShareableDictionary/ShareableDictionary+MapValues.swift" - "ShareableDictionary/ShareableDictionary+Merge.swift" - "ShareableDictionary/ShareableDictionary+Sendable.swift" - "ShareableDictionary/ShareableDictionary+Sequence.swift" - "ShareableDictionary/ShareableDictionary+Values.swift" - "ShareableDictionary/ShareableDictionary.swift" - "ShareableSet/ShareableSet+Codable.swift" - "ShareableSet/ShareableSet+Collection.swift" - "ShareableSet/ShareableSet+CustomReflectable.swift" - "ShareableSet/ShareableSet+Debugging.swift" - "ShareableSet/ShareableSet+Descriptions.swift" - "ShareableSet/ShareableSet+Equatable.swift" - "ShareableSet/ShareableSet+ExpressibleByArrayLiteral.swift" - "ShareableSet/ShareableSet+Extras.swift" - "ShareableSet/ShareableSet+Filter.swift" - "ShareableSet/ShareableSet+Hashable.swift" - "ShareableSet/ShareableSet+Sendable.swift" - "ShareableSet/ShareableSet+Sequence.swift" - "ShareableSet/ShareableSet+SetAlgebra Initializers.swift" - "ShareableSet/ShareableSet+SetAlgebra basics.swift" - "ShareableSet/ShareableSet+SetAlgebra formIntersection.swift" - "ShareableSet/ShareableSet+SetAlgebra formSymmetricDifference.swift" - "ShareableSet/ShareableSet+SetAlgebra formUnion.swift" - "ShareableSet/ShareableSet+SetAlgebra intersection.swift" - "ShareableSet/ShareableSet+SetAlgebra isDisjoint.swift" - "ShareableSet/ShareableSet+SetAlgebra isEqualSet.swift" - "ShareableSet/ShareableSet+SetAlgebra isStrictSubset.swift" - "ShareableSet/ShareableSet+SetAlgebra isStrictSuperset.swift" - "ShareableSet/ShareableSet+SetAlgebra isSubset.swift" - "ShareableSet/ShareableSet+SetAlgebra isSuperset.swift" - "ShareableSet/ShareableSet+SetAlgebra subtract.swift" - "ShareableSet/ShareableSet+SetAlgebra subtracting.swift" - "ShareableSet/ShareableSet+SetAlgebra symmetricDifference.swift" - "ShareableSet/ShareableSet+SetAlgebra union.swift" - "ShareableSet/ShareableSet.swift" - ) -target_link_libraries(ShareableHashedCollections PRIVATE - _CollectionsUtilities) -set_target_properties(ShareableHashedCollections PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) - -_install_target(ShareableHashedCollections) -set_property(GLOBAL APPEND PROPERTY SWIFT_COLLECTIONS_EXPORTS ShareableHashedCollections) diff --git a/Sources/_CollectionsTestSupport/Utilities/DictionaryAPIChecker.swift b/Sources/_CollectionsTestSupport/Utilities/DictionaryAPIChecker.swift index 8c60c9be..a686f753 100644 --- a/Sources/_CollectionsTestSupport/Utilities/DictionaryAPIChecker.swift +++ b/Sources/_CollectionsTestSupport/Utilities/DictionaryAPIChecker.swift @@ -134,7 +134,7 @@ public protocol DictionaryAPIExtras: DictionaryAPIChecker { ) rethrows -> R #if false - // Potential additions implemented by ShareableDictionary: + // Potential additions implemented by TreeDictionary: func contains(_ key: Key) -> Bool diff --git a/Tests/ShareableHashedCollectionsTests/Colliders.swift b/Tests/HashTreeCollectionsTests/Colliders.swift similarity index 100% rename from Tests/ShareableHashedCollectionsTests/Colliders.swift rename to Tests/HashTreeCollectionsTests/Colliders.swift diff --git a/Tests/ShareableHashedCollectionsTests/Hash.swift b/Tests/HashTreeCollectionsTests/Hash.swift similarity index 100% rename from Tests/ShareableHashedCollectionsTests/Hash.swift rename to Tests/HashTreeCollectionsTests/Hash.swift diff --git a/Tests/ShareableHashedCollectionsTests/ShareableDictionary Smoke Tests.swift b/Tests/HashTreeCollectionsTests/TreeDictionary Smoke Tests.swift similarity index 85% rename from Tests/ShareableHashedCollectionsTests/ShareableDictionary Smoke Tests.swift rename to Tests/HashTreeCollectionsTests/TreeDictionary Smoke Tests.swift index 9dc853c2..ed6e32a4 100644 --- a/Tests/ShareableHashedCollectionsTests/ShareableDictionary Smoke Tests.swift +++ b/Tests/HashTreeCollectionsTests/TreeDictionary Smoke Tests.swift @@ -10,17 +10,17 @@ //===----------------------------------------------------------------------===// import _CollectionsTestSupport -import ShareableHashedCollections +import HashTreeCollections -extension ShareableDictionary { +extension TreeDictionary { fileprivate func contains(_ key: Key) -> Bool { self[key] != nil } } -final class ShareableDictionarySmokeTests: CollectionTestCase { +final class TreeDictionarySmokeTests: CollectionTestCase { func testDummy() { - let map = ShareableDictionary( + let map = TreeDictionary( uniqueKeysWithValues: (0 ..< 100).map { ($0, 2 * $0) }) var it = map.makeIterator() var seen: Set = [] @@ -40,7 +40,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testSubscriptAdd() { - var map: ShareableDictionary = [1: "a", 2: "b"] + var map: TreeDictionary = [1: "a", 2: "b"] map[3] = "x" map[4] = "y" @@ -53,7 +53,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testSubscriptOverwrite() { - var map: ShareableDictionary = [1: "a", 2: "b"] + var map: TreeDictionary = [1: "a", 2: "b"] map[1] = "x" map[2] = "y" @@ -64,7 +64,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testSubscriptRemove() { - var map: ShareableDictionary = [1: "a", 2: "b"] + var map: TreeDictionary = [1: "a", 2: "b"] map[1] = nil map[2] = nil @@ -75,20 +75,20 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testTriggerOverwrite1() { - var map: ShareableDictionary = [1: "a", 2: "b"] + var map: TreeDictionary = [1: "a", 2: "b"] map.updateValue("x", forKey: 1) // triggers COW map.updateValue("y", forKey: 2) // triggers COW - var res1: ShareableDictionary = [:] + var res1: TreeDictionary = [:] res1.updateValue("a", forKey: 1) // in-place res1.updateValue("b", forKey: 2) // in-place - var res2: ShareableDictionary = [:] + var res2: TreeDictionary = [:] res2[1] = "a" // in-place res2[2] = "b" // in-place - var res3: ShareableDictionary = res2 + var res3: TreeDictionary = res2 res3[1] = "x" // triggers COW res3[2] = "y" // in-place @@ -102,7 +102,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testTriggerOverwrite2() { - var res1: ShareableDictionary = [:] + var res1: TreeDictionary = [:] res1.updateValue("a", forKey: Collider(10, 01)) // in-place res1.updateValue("a", forKey: Collider(11, 33)) // in-place res1.updateValue("b", forKey: Collider(20, 02)) // in-place @@ -111,7 +111,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { res1.updateValue("x", forKey: Collider(11, 33)) // in-place res1.updateValue("y", forKey: Collider(20, 02)) // in-place - var res2: ShareableDictionary = res1 + var res2: TreeDictionary = res1 res2.updateValue("a", forKey: Collider(10, 01)) // triggers COW res2.updateValue("a", forKey: Collider(11, 33)) // in-place res2.updateValue("b", forKey: Collider(20, 02)) // in-place @@ -130,13 +130,13 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { let upperBound = 1_000 // Populating `map1` - var map1: ShareableDictionary = [:] + var map1: TreeDictionary = [:] for index in 0.. = map1 + var map2: TreeDictionary = map1 for index in 0.. = map2 + var map3: TreeDictionary = map2 for index in 0.. = [1: "a", 2: "b"] + let map: TreeDictionary = [1: "a", 2: "b"] let hashPair1 = hashPair(1, "a") let hashPair2 = hashPair(2, "b") @@ -190,7 +190,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testCollisionNodeNotEqual() { - let map: ShareableDictionary = [:] + let map: TreeDictionary = [:] var res12 = map res12[Collider(1, 1)] = Collider(1, 1) @@ -210,7 +210,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testCompactionWhenDeletingFromHashCollisionNode1() { - let map: ShareableDictionary = [:] + let map: TreeDictionary = [:] var res1 = map @@ -221,7 +221,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectTrue(res1.contains(Collider(12, 1))) expectEqual(res1.count, 2) - expectEqual(ShareableDictionary([ + expectEqual(TreeDictionary([ Collider(11, 1): Collider(11, 1), Collider(12, 1): Collider(12, 1) ]), res1) @@ -235,7 +235,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res2.count, 1) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(11, 1): Collider(11, 1) ]), res2) @@ -249,7 +249,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res3.count, 1) expectEqual( - ShareableDictionary([Collider(12, 1): Collider(12, 1)]), + TreeDictionary([Collider(12, 1): Collider(12, 1)]), res3) @@ -263,7 +263,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(resX.count, 2) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(11, 1): Collider(11, 1), Collider(32769): Collider(32769)]), resX) @@ -279,14 +279,14 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(resY.count, 2) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(11, 1): Collider(11, 1), Collider(12, 1): Collider(12, 1)]), resY) } func testCompactionWhenDeletingFromHashCollisionNode2() { - let map: ShareableDictionary = [:] + let map: TreeDictionary = [:] var res1 = map @@ -298,7 +298,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res1.count, 2) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(32769_1, 32769): Collider(32769_1, 32769), Collider(32769_2, 32769): Collider(32769_2, 32769)]), res1) @@ -313,7 +313,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res2.count, 3) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(1): Collider(1), Collider(32769_1, 32769): Collider(32769_1, 32769), Collider(32769_2, 32769): Collider(32769_2, 32769)]), @@ -328,14 +328,14 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res3.count, 2) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(1): Collider(1), Collider(32769_1, 32769): Collider(32769_1, 32769)]), res3) } func testCompactionWhenDeletingFromHashCollisionNode3() { - let map: ShareableDictionary = [:] + let map: TreeDictionary = [:] var res1 = map @@ -347,7 +347,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res1.count, 2) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(32769_1, 32769): Collider(32769_1, 32769), Collider(32769_2, 32769): Collider(32769_2, 32769)]), res1) @@ -362,7 +362,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res2.count, 3) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(1): Collider(1), Collider(32769_1, 32769): Collider(32769_1, 32769), Collider(32769_2, 32769): Collider(32769_2, 32769)]), @@ -377,7 +377,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res3.count, 2) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(32769_1, 32769): Collider(32769_1, 32769), Collider(32769_2, 32769): Collider(32769_2, 32769)]), res3) @@ -387,7 +387,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testCompactionWhenDeletingFromHashCollisionNode4() { - let map: ShareableDictionary = [:] + let map: TreeDictionary = [:] var res1 = map @@ -399,7 +399,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res1.count, 2) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(32769_1, 32769): Collider(32769_1, 32769), Collider(32769_2, 32769): Collider(32769_2, 32769)]), res1) @@ -414,7 +414,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res2.count, 3) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(5): Collider(5), Collider(32769_1, 32769): Collider(32769_1, 32769), Collider(32769_2, 32769): Collider(32769_2, 32769)]), @@ -429,7 +429,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res3.count, 2) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(32769_1, 32769): Collider(32769_1, 32769), Collider(32769_2, 32769): Collider(32769_2, 32769)]), res3) @@ -439,7 +439,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testCompactionWhenDeletingFromHashCollisionNode5() { - let map: ShareableDictionary = [:] + let map: TreeDictionary = [:] var res1 = map @@ -455,7 +455,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res1.count, 4) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(1): Collider(1), Collider(1026): Collider(1026), Collider(32770_1, 32770): Collider(32770_1, 32770), @@ -473,14 +473,14 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { expectEqual(res2.count, 3) expectEqual( - ShareableDictionary([ + TreeDictionary([ Collider(1): Collider(1), Collider(32770_1, 32770): Collider(32770_1, 32770), Collider(32770_2, 32770): Collider(32770_2, 32770)]), res2) } - func inferSize(_ map: ShareableDictionary) -> Int { + func inferSize(_ map: TreeDictionary) -> Int { var size = 0 for _ in map { @@ -494,7 +494,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { let upperBound = 1_000 // '+' prefixed values - var map1: ShareableDictionary = [:] + var map1: TreeDictionary = [:] for index in 0.. = map1 + var map2: TreeDictionary = map1 for index in 0.. = map1 + var map3: TreeDictionary = map1 for index in 0.. = [:] + var map1: TreeDictionary = [:] for index in 0..( - _ map1: ShareableDictionary + _ map1: TreeDictionary ) { var count = 0 for _ in map1 { @@ -553,13 +553,13 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func testIteratorEnumeratesAll() { - let map1: ShareableDictionary = [ + let map1: TreeDictionary = [ Collider(11, 1): "a", Collider(12, 1): "a", Collider(32769): "b" ] - var map2: ShareableDictionary = [:] + var map2: TreeDictionary = [:] for (key, value) in map1 { map2[key] = value } @@ -571,7 +571,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { let a = Collider(1, "1000") let b = Collider(2, "1000") let c = Collider(3, "1001") - let map: ShareableDictionary = [ + let map: TreeDictionary = [ a: "a", b: "b", c: "c", @@ -579,7 +579,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { let indices = Array(map.indices) - typealias Index = ShareableDictionary.Index + typealias Index = TreeDictionary.Index expectEqual(map.index(forKey: a), indices[1]) expectEqual(map.index(forKey: b), indices[2]) expectEqual(map.index(forKey: c), indices[0]) @@ -588,7 +588,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { func test_indexForKey() { let input = 0 ..< 10_000 - let d = ShareableDictionary( + let d = TreeDictionary( uniqueKeysWithValues: input.lazy.map { ($0, 2 * $0) }) for key in input { expectNotNil(d.index(forKey: key)) { index in @@ -601,7 +601,7 @@ final class ShareableDictionarySmokeTests: CollectionTestCase { } func test_indexForKey_exhaustIndices() { - var map: ShareableDictionary = [:] + var map: TreeDictionary = [:] let range = 0 ..< 10_000 diff --git a/Tests/ShareableHashedCollectionsTests/ShareableDictionary Tests.swift b/Tests/HashTreeCollectionsTests/TreeDictionary Tests.swift similarity index 94% rename from Tests/ShareableHashedCollectionsTests/ShareableDictionary Tests.swift rename to Tests/HashTreeCollectionsTests/TreeDictionary Tests.swift index 1efef57c..8674350f 100644 --- a/Tests/ShareableHashedCollectionsTests/ShareableDictionary Tests.swift +++ b/Tests/HashTreeCollectionsTests/TreeDictionary Tests.swift @@ -10,13 +10,13 @@ //===----------------------------------------------------------------------===// import _CollectionsTestSupport -import ShareableHashedCollections +import HashTreeCollections -extension ShareableDictionary: DictionaryAPIExtras {} +extension TreeDictionary: DictionaryAPIExtras {} -class ShareableDictionaryTests: CollectionTestCase { +class TreeDictionaryTests: CollectionTestCase { func test_empty() { - let d = ShareableDictionary() + let d = TreeDictionary() expectEqualElements(d, []) expectEqual(d.count, 0) @@ -31,7 +31,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_remove_update_basics() throws { - var d = ShareableDictionary() + var d = TreeDictionary() d.updateValue(1, forKey: "One") d.updateValue(2, forKey: "Two") @@ -72,7 +72,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_subscript_setter_basics() throws { - var d = ShareableDictionary() + var d = TreeDictionary() d["One"] = 1 d["Two"] = 2 @@ -113,7 +113,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_add_remove() throws { - var d = ShareableDictionary() + var d = TreeDictionary() let c = 400 for i in 0 ..< c { @@ -143,7 +143,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_collisions() throws { - var d = ShareableDictionary() + var d = TreeDictionary() let count = 100 let groups = 20 @@ -174,7 +174,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_shared_copies() throws { - var d = ShareableDictionary() + var d = TreeDictionary() let c = 200 for i in 0 ..< c { @@ -201,7 +201,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_Sequence_basic() { - var d: ShareableDictionary = [1: 2] + var d: TreeDictionary = [1: 2] var it = d.makeIterator() expectEquivalent(it.next(), (1, 2), by: { $0 == $1 }) expectNil(it.next()) @@ -214,7 +214,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_Sequence_400() { - var d = ShareableDictionary() + var d = TreeDictionary() let c = 400 for i in 0 ..< c { expectNil(d.updateValue(i, forKey: i)) @@ -230,7 +230,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_Sequence_collisions() { - var d = ShareableDictionary() + var d = TreeDictionary() let count = 100 let groups = 20 @@ -262,7 +262,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_BidirectionalCollection_random100() { - let d = ShareableDictionary( + let d = TreeDictionary( uniqueKeysWithValues: (0 ..< 100).map { ($0, $0) }) let ref = Array(d) checkCollection(d, expectedContents: ref, by: ==) @@ -297,13 +297,13 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_Encodable() throws { - let d1: ShareableDictionary = [ + let d1: TreeDictionary = [ "one": 1, "two": 2, "three": 3] let v1: MinimalEncoder.Value = .dictionary([ "one": .int(1), "two": .int(2), "three": .int(3)]) expectEqual(try MinimalEncoder.encode(d1), v1) - let d2: ShareableDictionary = [ + let d2: TreeDictionary = [ 1: "one", 2: "two", 3: "three"] let v2: MinimalEncoder.Value = .dictionary([ "1": .string("one"), @@ -314,7 +314,7 @@ class ShareableDictionaryTests: CollectionTestCase { #if swift(>=5.6) if #available(macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4, *) { - let d3: ShareableDictionary = [ + let d3: TreeDictionary = [ FancyDictionaryKey(1): 10, FancyDictionaryKey(2): 20 ] let v3: MinimalEncoder.Value = .dictionary([ @@ -324,7 +324,7 @@ class ShareableDictionaryTests: CollectionTestCase { } #endif - let d4: ShareableDictionary = [ + let d4: TreeDictionary = [ // Note: we only have a single element to prevent ordering // problems. BoringDictionaryKey(42): 23 @@ -337,9 +337,9 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_Decodable() throws { - typealias PD = ShareableDictionary + typealias PD = TreeDictionary - let d1: ShareableDictionary = [ + let d1: TreeDictionary = [ "one": 1, "two": 2, "three": 3] let v1: MinimalEncoder.Value = .dictionary([ "one": .int(1), "two": .int(2), "three": .int(3)]) @@ -347,7 +347,7 @@ class ShareableDictionaryTests: CollectionTestCase { try MinimalDecoder.decode(v1, as: PD.self), d1) - let d2: ShareableDictionary = [ + let d2: TreeDictionary = [ 1: "one", 2: "two", 3: "three"] let v2: MinimalEncoder.Value = .dictionary([ "1": .string("one"), @@ -360,7 +360,7 @@ class ShareableDictionaryTests: CollectionTestCase { #if swift(>=5.6) if #available(macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4, *) { - let d3: ShareableDictionary = [ + let d3: TreeDictionary = [ FancyDictionaryKey(1): 10, FancyDictionaryKey(2): 20 ] let v3: MinimalEncoder.Value = .dictionary([ @@ -372,7 +372,7 @@ class ShareableDictionaryTests: CollectionTestCase { } #endif - let d4: ShareableDictionary = [ + let d4: TreeDictionary = [ // Note: we only have a single element to prevent ordering // problems. BoringDictionaryKey(42): 23 @@ -425,7 +425,7 @@ class ShareableDictionaryTests: CollectionTestCase { func test_CustomReflectable() { do { - let d: ShareableDictionary = [1: 2, 3: 4, 5: 6] + let d: TreeDictionary = [1: 2, 3: 4, 5: 6] let mirror = Mirror(reflecting: d) expectEqual(mirror.displayStyle, .dictionary) expectNil(mirror.superclassMirror) @@ -437,7 +437,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_Equatable_Hashable() { - let samples: [[ShareableDictionary]] = [ + let samples: [[TreeDictionary]] = [ [[:], [:]], [[1: 100], [1: 100]], [[2: 200], [2: 200]], @@ -457,15 +457,15 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_CustomStringConvertible() { - let a: ShareableDictionary = [:] + let a: TreeDictionary = [:] expectEqual(a.description, "[:]") - let b: ShareableDictionary = [ + let b: TreeDictionary = [ RawCollider(0): 1 ] expectEqual(b.description, "[0#0: 1]") - let c: ShareableDictionary = [ + let c: TreeDictionary = [ RawCollider(0): 1, RawCollider(2): 3, RawCollider(4): 5, @@ -474,26 +474,26 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_CustomDebugStringConvertible() { - let a: ShareableDictionary = [:] + let a: TreeDictionary = [:] expectEqual( a.debugDescription, - "ShareableDictionary([:])") + "TreeDictionary([:])") - let b: ShareableDictionary = [0: 1] + let b: TreeDictionary = [0: 1] expectEqual( b.debugDescription, - "ShareableDictionary([0: 1])") + "TreeDictionary([0: 1])") - let c: ShareableDictionary = [0: 1, 2: 3, 4: 5] + let c: TreeDictionary = [0: 1, 2: 3, 4: 5] let cd = c.map { "\($0.key): \($0.value)"}.joined(separator: ", ") expectEqual( c.debugDescription, - "ShareableDictionary([\(cd)])") + "TreeDictionary([\(cd)])") } func test_index_descriptions() { - let a: ShareableDictionary = [ + let a: TreeDictionary = [ RawCollider(1, "1"): 1, RawCollider(2, "21"): 2, RawCollider(3, "22"): 3, @@ -521,7 +521,7 @@ class ShareableDictionaryTests: CollectionTestCase { withEachFixture { fixture in withEvery("isShared", in: [false, true]) { isShared in withLifetimeTracking { tracker in - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] withEvery("i", in: 0 ..< fixture.count) { i in withHiddenCopies(if: isShared, of: &d) { d in @@ -545,7 +545,7 @@ class ShareableDictionaryTests: CollectionTestCase { withEachFixture { fixture in withEvery("isShared", in: [false, true]) { isShared in withLifetimeTracking { tracker in - var d: ShareableDictionary, Empty> = [:] + var d: TreeDictionary, Empty> = [:] var ref: Dictionary, Empty> = [:] withEvery("i", in: 0 ..< fixture.count) { i in withHiddenCopies(if: isShared, of: &d) { d in @@ -742,7 +742,7 @@ class ShareableDictionaryTests: CollectionTestCase { for: (0 ..< count).map { generator.key(for: $0) }) let values = tracker.instances( for: (0 ..< count).map { generator.value(for: $0) }) - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] withEvery("offset", in: 0 ..< count) { offset in withHiddenCopies(if: isShared, of: &d) { d in @@ -764,7 +764,7 @@ class ShareableDictionaryTests: CollectionTestCase { withEachFixture { fixture in withEvery("isShared", in: [false, true]) { isShared in withLifetimeTracking { tracker in - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] withEvery("i", in: 0 ..< fixture.count) { i in withHiddenCopies(if: isShared, of: &d) { d in @@ -804,7 +804,7 @@ class ShareableDictionaryTests: CollectionTestCase { func test_subscript_modify_basics() { func check(count: Int, generator: G) where G.Value == Int { context.withTrace("count: \(count), generator: \(generator)") { - var d: ShareableDictionary = [:] + var d: TreeDictionary = [:] var ref: Dictionary = [:] // Insertions @@ -968,7 +968,7 @@ class ShareableDictionaryTests: CollectionTestCase { for: (0 ..< count).map { generator.key(for: $0) }) let values = tracker.instances( for: (0 ..< count).map { generator.value(for: $0) }) - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] withEvery("offset", in: 0 ..< count) { offset in withHiddenCopies(if: isShared, of: &d) { d in @@ -994,7 +994,7 @@ class ShareableDictionaryTests: CollectionTestCase { withEvery("seed", in: 0..<3) { seed in withEvery("isShared", in: [false, true]) { isShared in withLifetimeTracking { tracker in - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] withEvery("i", in: 0 ..< fixture.count) { i in withHiddenCopies(if: isShared, of: &d) { d in @@ -1039,7 +1039,7 @@ class ShareableDictionaryTests: CollectionTestCase { } func test_defaulted_subscript_basics() { - var d: ShareableDictionary = [:] + var d: TreeDictionary = [:] expectEqual(d[1, default: 0], 0) @@ -1127,7 +1127,7 @@ class ShareableDictionaryTests: CollectionTestCase { for: (0 ..< count).map { generator.key(for: $0) }) let values = tracker.instances( for: (0 ..< count).map { generator.value(for: $0) }) - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] let def = tracker.instance(for: generator.value(for: -1000)) withEvery("offset", in: 0 ..< count) { offset in @@ -1151,7 +1151,7 @@ class ShareableDictionaryTests: CollectionTestCase { withEvery("seed", in: 0..<3) { seed in withEvery("isShared", in: [false, true]) { isShared in withLifetimeTracking { tracker in - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] let def = tracker.instance(for: -1000) withEvery("i", in: 0 ..< fixture.count) { i in @@ -1247,7 +1247,7 @@ class ShareableDictionaryTests: CollectionTestCase { let values = tracker.instances( for: (0 ..< count).map { generator.value(for: $0) }) let def = tracker.instance(for: generator.value(for: -1000)) - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] withEvery("offset", in: 0 ..< count) { offset in withHiddenCopies(if: isShared, of: &d) { d in @@ -1274,7 +1274,7 @@ class ShareableDictionaryTests: CollectionTestCase { withEvery("seed", in: 0..<3) { seed in withEvery("isShared", in: [false, true]) { isShared in withLifetimeTracking { tracker in - var d: ShareableDictionary, LifetimeTracked> = [:] + var d: TreeDictionary, LifetimeTracked> = [:] var ref: Dictionary, LifetimeTracked> = [:] let def = tracker.instance(for: -1) withEvery("i", in: 0 ..< fixture.count) { i in @@ -1358,7 +1358,7 @@ class ShareableDictionaryTests: CollectionTestCase { func test_mapValues_basics() { let items = (0 ..< 100).map { ($0, 100 * $0) } - let d = ShareableDictionary(uniqueKeysWithValues: items) + let d = TreeDictionary(uniqueKeysWithValues: items) var c = 0 let d2 = d.mapValues { value -> String in @@ -1393,7 +1393,7 @@ class ShareableDictionaryTests: CollectionTestCase { func test_compactMapValues_basics() { let items = (0 ..< 100).map { ($0, 100 * $0) } - let d = ShareableDictionary(uniqueKeysWithValues: items) + let d = TreeDictionary(uniqueKeysWithValues: items) var c = 0 let d2 = d.compactMapValues { value -> String? in @@ -1440,7 +1440,7 @@ class ShareableDictionaryTests: CollectionTestCase { func test_filter_basics() { let items = (0 ..< 100).map { ($0, 100 * $0) } - let d = ShareableDictionary(uniqueKeysWithValues: items) + let d = TreeDictionary(uniqueKeysWithValues: items) var c = 0 let d2 = d.filter { item in @@ -1506,7 +1506,7 @@ class ShareableDictionaryTests: CollectionTestCase { func test_filter_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableDictionary( + let x = TreeDictionary( uniqueKeysWithValues: a.lazy.map { ($0, $0.identity + 100) }) @@ -1524,7 +1524,7 @@ class ShareableDictionaryTests: CollectionTestCase { withEvery("isShared", in: [false, true]) { isShared in withEverySubset("a", of: testItems) { a in withEverySubset("b", of: a) { b in - var x = ShareableDictionary( + var x = TreeDictionary( uniqueKeysWithValues: a.lazy.map { ($0, $0.identity + 100) }) @@ -1584,7 +1584,7 @@ class ShareableDictionaryTests: CollectionTestCase { // "two": 2, // "three": 3, // ] - // let d = ShareableDictionary(uniqueKeysWithValues: items) + // let d = TreeDictionary(uniqueKeysWithValues: items) // expectEqualElements(d.sorted(by: <), items.sorted(by: <)) // } @@ -1595,7 +1595,7 @@ class ShareableDictionaryTests: CollectionTestCase { // "two": 2, // "three": 3, // ] - // let d = ShareableDictionary(uniqueKeysWithValues: items) + // let d = TreeDictionary(uniqueKeysWithValues: items) // expectEqualElements(d.sorted(by: <), items.sorted(by: <)) // } @@ -1606,7 +1606,7 @@ class ShareableDictionaryTests: CollectionTestCase { ("two", 2), ("three", 3), ] - let d = ShareableDictionary(uniqueKeysWithValues: items) + let d = TreeDictionary(uniqueKeysWithValues: items) expectEqualElements(d.sorted(by: <), items.sorted(by: <)) } @@ -1620,7 +1620,7 @@ class ShareableDictionaryTests: CollectionTestCase { // "b": 1, // "d": 3, // ] - // let d = ShareableDictionary(items, uniquingKeysWith: +) + // let d = TreeDictionary(items, uniquingKeysWith: +) // expectEqualElements(d, [ // (key: "a", value: 5), // (key: "b", value: 2), @@ -1639,7 +1639,7 @@ class ShareableDictionaryTests: CollectionTestCase { // ("b", 1), // ("d", 3), // ] - // let d = ShareableDictionary(items, uniquingKeysWith: +) + // let d = TreeDictionary(items, uniquingKeysWith: +) // expectEqualElements(d, [ // (key: "a", value: 5), // (key: "b", value: 2), @@ -1653,7 +1653,7 @@ class ShareableDictionaryTests: CollectionTestCase { // "one", "two", "three", "four", "five", // "six", "seven", "eight", "nine", "ten" // ] - // let d = ShareableDictionary( + // let d = TreeDictionary( // grouping: items, // by: { $0.count }) // expectEqualElements(d, [ @@ -1670,7 +1670,7 @@ class ShareableDictionaryTests: CollectionTestCase { // "two": 2, // "three": 3, // ] - // let d = ShareableDictionary(uniqueKeysWithValues: items) + // let d = TreeDictionary(uniqueKeysWithValues: items) // expectEqualElements(d, items) // } @@ -1681,15 +1681,15 @@ class ShareableDictionaryTests: CollectionTestCase { // ("two", 2), // ("three", 3), // ] - // let d = ShareableDictionary(uniqueKeysWithValues: items) + // let d = TreeDictionary(uniqueKeysWithValues: items) // expectEqualElements(d, items) // } func test_ExpressibleByDictionaryLiteral() { - let d0: ShareableDictionary = [:] + let d0: TreeDictionary = [:] expectTrue(d0.isEmpty) - let d1: ShareableDictionary = [ + let d1: TreeDictionary = [ "1~one": 1, "2~two": 2, "3~three": 3, @@ -1704,7 +1704,7 @@ class ShareableDictionaryTests: CollectionTestCase { } // func test_keys() { - // let d: ShareableDictionary = [ + // let d: TreeDictionary = [ // "one": 1, // "two": 2, // "three": 3, @@ -1752,7 +1752,7 @@ class ShareableDictionaryTests: CollectionTestCase { withLifetimeTracking { tracker in let (d, _, _) = tracker.shareableDictionary(keys: 0 ..< count) withEvery("offset", in: 0 ..< count) { offset in - let item = d[ShareableDictionaryIndex(value: offset)] + let item = d[TreeDictionaryIndex(value: offset)] // NOTE: uses the actual order `d.keys` expectEqual(item.key, d.keys[offset]) // NOTE: uses the actual order `d.values` @@ -1828,7 +1828,7 @@ class ShareableDictionaryTests: CollectionTestCase { // withLifetimeTracking { tracker in // let keys = tracker.instances(for: 0 ..< count) // let values = tracker.instances(for: (0 ..< count).map { 100 + $0 }) -// var d: ShareableDictionary, LifetimeTracked> = [:] +// var d: TreeDictionary, LifetimeTracked> = [:] // withEvery("offset", in: 0 ..< count) { offset in // withHiddenCopies(if: isShared, of: &d) { d in // d[keys[offset]] = values[offset] @@ -1917,7 +1917,7 @@ class ShareableDictionaryTests: CollectionTestCase { // withLifetimeTracking { tracker in // let keys = tracker.instances(for: 0 ..< count) // let values = tracker.instances(for: (0 ..< count).map { 100 + $0 }) - // var d: ShareableDictionary, LifetimeTracked> = [:] + // var d: TreeDictionary, LifetimeTracked> = [:] // withEvery("offset", in: 0 ..< count) { offset in // withHiddenCopies(if: isShared, of: &d) { d in // mutate(&d[keys[offset]]) { v in @@ -2013,7 +2013,7 @@ class ShareableDictionaryTests: CollectionTestCase { // withLifetimeTracking { tracker in // let keys = tracker.instances(for: 0 ..< count) // let values = tracker.instances(for: (0 ..< count).map { 100 + $0 }) - // var d: ShareableDictionary, LifetimeTracked> = [:] + // var d: TreeDictionary, LifetimeTracked> = [:] // let fallback = tracker.instance(for: -1) // withEvery("offset", in: 0 ..< count) { offset in // withHiddenCopies(if: isShared, of: &d) { d in @@ -2065,7 +2065,7 @@ class ShareableDictionaryTests: CollectionTestCase { // withLifetimeTracking { tracker in // let keys = tracker.instances(for: 0 ..< count) // let values = tracker.instances(for: (0 ..< count).map { 100 + $0 }) - // var d: ShareableDictionary, LifetimeTracked> = [:] + // var d: TreeDictionary, LifetimeTracked> = [:] // withEvery("offset", in: 0 ..< count) { offset in // withHiddenCopies(if: isShared, of: &d) { d in // let key = keys[offset] @@ -2116,7 +2116,7 @@ class ShareableDictionaryTests: CollectionTestCase { // withLifetimeTracking { tracker in // let keys = tracker.instances(for: 0 ..< count) // let values = tracker.instances(for: (0 ..< count).map { 100 + $0 }) - // var d: ShareableDictionary, LifetimeTracked> = [:] + // var d: TreeDictionary, LifetimeTracked> = [:] // withEvery("offset", in: 0 ..< count) { offset in // withHiddenCopies(if: isShared, of: &d) { d in // let key = keys[count - 1 - offset] @@ -2171,7 +2171,7 @@ class ShareableDictionaryTests: CollectionTestCase { // withLifetimeTracking { tracker in // let keys = tracker.instances(for: 0 ..< count) // let values = tracker.instances(for: (0 ..< count).map { 100 + $0 }) - // var d: ShareableDictionary, LifetimeTracked> = [:] + // var d: TreeDictionary, LifetimeTracked> = [:] // let fallback = tracker.instance(for: -2) // withEvery("offset", in: 0 ..< count) { offset in // withHiddenCopies(if: isShared, of: &d) { d in @@ -2227,7 +2227,7 @@ class ShareableDictionaryTests: CollectionTestCase { // withLifetimeTracking { tracker in // let keys = tracker.instances(for: 0 ..< count) // let values = tracker.instances(for: (0 ..< count).map { 100 + $0 }) - // var d: ShareableDictionary, LifetimeTracked> = [:] + // var d: TreeDictionary, LifetimeTracked> = [:] // let fallback = tracker.instance(for: -2) // withEvery("offset", in: 0 ..< count) { offset in // withHiddenCopies(if: isShared, of: &d) { d in @@ -2277,7 +2277,7 @@ class ShareableDictionaryTests: CollectionTestCase { // } // func test_merge_labeled_tuple() { - // var d: ShareableDictionary = [ + // var d: TreeDictionary = [ // "one": 1, // "two": 1, // "three": 1, @@ -2302,7 +2302,7 @@ class ShareableDictionaryTests: CollectionTestCase { // } // func test_merge_unlabeled_tuple() { - // var d: ShareableDictionary = [ + // var d: TreeDictionary = [ // "one": 1, // "two": 1, // "three": 1, @@ -2327,7 +2327,7 @@ class ShareableDictionaryTests: CollectionTestCase { // } // func test_merging_labeled_tuple() { - // let d: ShareableDictionary = [ + // let d: TreeDictionary = [ // "one": 1, // "two": 1, // "three": 1, @@ -2358,7 +2358,7 @@ class ShareableDictionaryTests: CollectionTestCase { // } // func test_merging_unlabeled_tuple() { - // let d: ShareableDictionary = [ + // let d: TreeDictionary = [ // "one": 1, // "two": 1, // "three": 1, @@ -2390,7 +2390,7 @@ class ShareableDictionaryTests: CollectionTestCase { // func test_filter() { // let items = (0 ..< 100).map { ($0, 100 * $0) } - // let d = ShareableDictionary(uniqueKeysWithValues: items) + // let d = TreeDictionary(uniqueKeysWithValues: items) // // var c = 0 // let d2 = d.filter { item in @@ -2408,7 +2408,7 @@ class ShareableDictionaryTests: CollectionTestCase { // func test_mapValues() { // let items = (0 ..< 100).map { ($0, 100 * $0) } - // let d = ShareableDictionary(uniqueKeysWithValues: items) + // let d = TreeDictionary(uniqueKeysWithValues: items) // // var c = 0 // let d2 = d.mapValues { value -> String in @@ -2426,7 +2426,7 @@ class ShareableDictionaryTests: CollectionTestCase { // func test_compactMapValue() { // let items = (0 ..< 100).map { ($0, 100 * $0) } - // let d = ShareableDictionary(uniqueKeysWithValues: items) + // let d = TreeDictionary(uniqueKeysWithValues: items) // // var c = 0 // let d2 = d.compactMapValues { value -> String? in @@ -2501,7 +2501,7 @@ class ShareableDictionaryTests: CollectionTestCase { // } // func test_removeSubrange_rangeExpression() { - // let d = ShareableDictionary(uniqueKeys: 0 ..< 30, values: 100 ..< 130) + // let d = TreeDictionary(uniqueKeys: 0 ..< 30, values: 100 ..< 130) // let item = (0 ..< 30).map { (key: $0, value: 100 + $0) } // // var d1 = d diff --git a/Tests/ShareableHashedCollectionsTests/ShareableDictionary.Keys Tests.swift b/Tests/HashTreeCollectionsTests/TreeDictionary.Keys Tests.swift similarity index 82% rename from Tests/ShareableHashedCollectionsTests/ShareableDictionary.Keys Tests.swift rename to Tests/HashTreeCollectionsTests/TreeDictionary.Keys Tests.swift index f5a4c2ee..c714b187 100644 --- a/Tests/ShareableHashedCollectionsTests/ShareableDictionary.Keys Tests.swift +++ b/Tests/HashTreeCollectionsTests/TreeDictionary.Keys Tests.swift @@ -11,9 +11,9 @@ import XCTest import _CollectionsTestSupport -import ShareableHashedCollections +import HashTreeCollections -class ShareableDictionaryKeysTests: CollectionTestCase { +class TreeDictionaryKeysTests: CollectionTestCase { func test_BidirectionalCollection_fixtures() { withEachFixture { fixture in withLifetimeTracking { tracker in @@ -27,7 +27,7 @@ class ShareableDictionaryKeysTests: CollectionTestCase { } func test_descriptions() { - let d: ShareableDictionary = [ + let d: TreeDictionary = [ "a": 1, "b": 2 ] @@ -36,18 +36,18 @@ class ShareableDictionaryKeysTests: CollectionTestCase { expectEqual(d.keys.description, "[a, b]") expectEqual( d.keys.debugDescription, - "ShareableDictionary.Keys([\"a\", \"b\"])") + "TreeDictionary.Keys([\"a\", \"b\"])") } else { expectEqual(d.keys.description, "[b, a]") expectEqual( d.keys.debugDescription, - "ShareableDictionary.Keys([\"b\", \"a\"])") + "TreeDictionary.Keys([\"b\", \"a\"])") } } func test_contains() { withEverySubset("a", of: testItems) { a in - let x = ShareableDictionary( + let x = TreeDictionary( uniqueKeysWithValues: a.lazy.map { ($0, 2 * $0.identity) }) let u = Set(a) @@ -68,15 +68,15 @@ class ShareableDictionaryKeysTests: CollectionTestCase { func test_intersection_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableDictionary( + let x = TreeDictionary( uniqueKeysWithValues: a.lazy.map { ($0, 2 * $0.identity) }) let u = Set(a) expectEqualSets(x.keys.intersection(x.keys), u) withEverySubset("b", of: testItems) { b in - let y = ShareableDictionary( + let y = TreeDictionary( uniqueKeysWithValues: b.lazy.map { ($0, -$0.identity - 1) }) let v = Set(b) - let z = ShareableSet(b) + let z = TreeSet(b) let reference = u.intersection(v) @@ -88,15 +88,15 @@ class ShareableDictionaryKeysTests: CollectionTestCase { func test_subtracting_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableDictionary( + let x = TreeDictionary( uniqueKeysWithValues: a.lazy.map { ($0, 2 * $0.identity) }) let u = Set(a) expectEqualSets(x.keys.subtracting(x.keys), []) withEverySubset("b", of: testItems) { b in - let y = ShareableDictionary( + let y = TreeDictionary( uniqueKeysWithValues: b.lazy.map { ($0, -$0.identity - 1) }) let v = Set(b) - let z = ShareableSet(b) + let z = TreeSet(b) let reference = u.subtracting(v) diff --git a/Tests/ShareableHashedCollectionsTests/ShareableDictionary.Values Tests.swift b/Tests/HashTreeCollectionsTests/TreeDictionary.Values Tests.swift similarity index 89% rename from Tests/ShareableHashedCollectionsTests/ShareableDictionary.Values Tests.swift rename to Tests/HashTreeCollectionsTests/TreeDictionary.Values Tests.swift index 47609c0d..b64f8ef4 100644 --- a/Tests/ShareableHashedCollectionsTests/ShareableDictionary.Values Tests.swift +++ b/Tests/HashTreeCollectionsTests/TreeDictionary.Values Tests.swift @@ -11,9 +11,9 @@ import XCTest import _CollectionsTestSupport -import ShareableHashedCollections +import HashTreeCollections -class ShareableDictionaryValuesTests: CollectionTestCase { +class TreeDictionaryValuesTests: CollectionTestCase { func test_BidirectionalCollection_fixtures() { withEachFixture { fixture in withLifetimeTracking { tracker in @@ -27,7 +27,7 @@ class ShareableDictionaryValuesTests: CollectionTestCase { } func test_descriptions() { - let d: ShareableDictionary = [ + let d: TreeDictionary = [ "a": 1, "b": 2 ] diff --git a/Tests/ShareableHashedCollectionsTests/ShareableHashedCollections Fixtures.swift b/Tests/HashTreeCollectionsTests/TreeHashedCollections Fixtures.swift similarity index 92% rename from Tests/ShareableHashedCollectionsTests/ShareableHashedCollections Fixtures.swift rename to Tests/HashTreeCollectionsTests/TreeHashedCollections Fixtures.swift index 6c260abb..5b792306 100644 --- a/Tests/ShareableHashedCollectionsTests/ShareableHashedCollections Fixtures.swift +++ b/Tests/HashTreeCollectionsTests/TreeHashedCollections Fixtures.swift @@ -10,7 +10,7 @@ //===----------------------------------------------------------------------===// import _CollectionsTestSupport -import ShareableHashedCollections +import HashTreeCollections /// A set of items whose subsets will produce a bunch of interesting test /// cases. @@ -37,20 +37,20 @@ extension LifetimeTracker { for items: C, keyTransform: (C.Element) -> Key, valueTransform: (C.Element) -> Value - ) -> ShareableDictionary, LifetimeTracked> { + ) -> TreeDictionary, LifetimeTracked> { let keys = instances(for: items, by: keyTransform) let values = instances(for: items, by: valueTransform) - return ShareableDictionary(uniqueKeysWithValues: zip(keys, values)) + return TreeDictionary(uniqueKeysWithValues: zip(keys, values)) } func shareableDictionary( for keys: C, by valueTransform: (C.Element) -> Value - ) -> ShareableDictionary, LifetimeTracked> + ) -> TreeDictionary, LifetimeTracked> where C.Element: Hashable { let k = instances(for: keys) let v = instances(for: keys, by: valueTransform) - return ShareableDictionary(uniqueKeysWithValues: zip(k, v)) + return TreeDictionary(uniqueKeysWithValues: zip(k, v)) } func dictionary( @@ -266,7 +266,7 @@ struct Fixture { init(title: String, contents: [String]) { self.title = title - let maxDepth = ShareableDictionary._maxDepth + let maxDepth = TreeDictionary._maxDepth func normalized(_ path: String) -> String { precondition(path.unicodeScalars.count < maxDepth) @@ -361,7 +361,7 @@ extension LifetimeTracker { for fixture: Fixture, with transform: (RawCollider) -> Element ) -> ( - map: ShareableSet>, + map: TreeSet>, ref: [LifetimeTracked] ) { let ref = fixture.itemsInIterationOrder.map { key in @@ -370,13 +370,13 @@ extension LifetimeTracker { let ref2 = fixture.itemsInInsertionOrder.map { key in self.instance(for: transform(key)) } - return (ShareableSet(ref2), ref) + return (TreeSet(ref2), ref) } func shareableSet( for fixture: Fixture ) -> ( - map: ShareableSet>, + map: TreeSet>, ref: [LifetimeTracked] ) { shareableSet(for: fixture) { key in key } @@ -387,7 +387,7 @@ extension LifetimeTracker { keyTransform: (RawCollider) -> Key, valueTransform: (RawCollider) -> Value ) -> ( - map: ShareableDictionary, LifetimeTracked>, + map: TreeDictionary, LifetimeTracked>, ref: [(key: LifetimeTracked, value: LifetimeTracked)] ) { typealias K = LifetimeTracked @@ -403,14 +403,14 @@ extension LifetimeTracker { let value = valueTransform(item) return (key: self.instance(for: key), value: self.instance(for: value)) } - return (ShareableDictionary(uniqueKeysWithValues: ref2), ref) + return (TreeDictionary(uniqueKeysWithValues: ref2), ref) } func shareableDictionary( for fixture: Fixture, valueTransform: (Int) -> Value ) -> ( - map: ShareableDictionary, LifetimeTracked>, + map: TreeDictionary, LifetimeTracked>, ref: [(key: LifetimeTracked, value: LifetimeTracked)] ) { shareableDictionary( @@ -422,7 +422,7 @@ extension LifetimeTracker { func shareableDictionary( for fixture: Fixture ) -> ( - map: ShareableDictionary, LifetimeTracked>, + map: TreeDictionary, LifetimeTracked>, ref: [(key: LifetimeTracked, value: LifetimeTracked)] ) { shareableDictionary(for: fixture) { $0 + 1000 } diff --git a/Tests/ShareableHashedCollectionsTests/ShareableSet Tests.swift b/Tests/HashTreeCollectionsTests/TreeSet Tests.swift similarity index 83% rename from Tests/ShareableHashedCollectionsTests/ShareableSet Tests.swift rename to Tests/HashTreeCollectionsTests/TreeSet Tests.swift index b9e7cc4d..9ea87177 100644 --- a/Tests/ShareableHashedCollectionsTests/ShareableSet Tests.swift +++ b/Tests/HashTreeCollectionsTests/TreeSet Tests.swift @@ -10,13 +10,13 @@ //===----------------------------------------------------------------------===// import _CollectionsTestSupport -import ShareableHashedCollections +import HashTreeCollections -extension ShareableSet: SetAPIExtras {} +extension TreeSet: SetAPIExtras {} -class ShareableSetTests: CollectionTestCase { +class TreeSetTests: CollectionTestCase { func test_init_empty() { - let set = ShareableSet() + let set = TreeSet() expectEqual(set.count, 0) expectTrue(set.isEmpty) expectEqualElements(set, []) @@ -34,7 +34,7 @@ class ShareableSetTests: CollectionTestCase { } func test_BidirectionalCollection_random100() { - let s = ShareableSet(0 ..< 100) + let s = TreeSet(0 ..< 100) let ref = Array(s) checkCollection(s, expectedContents: ref) _checkBidirectionalCollection_indexOffsetBy( @@ -42,7 +42,7 @@ class ShareableSetTests: CollectionTestCase { } func test_basics() { - var set: ShareableSet> = [] + var set: TreeSet> = [] let a1 = HashableBox(1) let a2 = HashableBox(1) @@ -81,17 +81,17 @@ class ShareableSetTests: CollectionTestCase { } func test_descriptions() { - let empty: ShareableSet = [] + let empty: TreeSet = [] expectEqual(empty.description, "[]") - expectEqual(empty.debugDescription, "ShareableSet([])") + expectEqual(empty.debugDescription, "TreeSet([])") - let a: ShareableSet = ["a"] + let a: TreeSet = ["a"] expectEqual(a.description, "[a]") - expectEqual(a.debugDescription, "ShareableSet([\"a\"])") + expectEqual(a.debugDescription, "TreeSet([\"a\"])") } func test_index_descriptions() { - let a: ShareableSet = [ + let a: TreeSet = [ RawCollider(1, "1"), RawCollider(2, "21"), RawCollider(3, "22"), @@ -114,7 +114,7 @@ class ShareableSetTests: CollectionTestCase { } func test_index_hashing() { - let s = ShareableSet(0 ..< 100) + let s = TreeSet(0 ..< 100) checkHashable(s.indices, equalityOracle: ==) } @@ -122,7 +122,7 @@ class ShareableSetTests: CollectionTestCase { withEachFixture { fixture in withEvery("isShared", in: [false, true]) { isShared in withLifetimeTracking { tracker in - var s: ShareableSet> = [] + var s: TreeSet> = [] var ref: Set> = [] withEvery("i", in: 0 ..< fixture.count) { i in withHiddenCopies(if: isShared, of: &s) { s in @@ -167,9 +167,9 @@ class ShareableSetTests: CollectionTestCase { let b = RawCollider(2, "B") let c = RawCollider(3, "C") - let s0: ShareableSet = [] - let s1: ShareableSet = [a, b] - let s2: ShareableSet = [a, c] + let s0: TreeSet = [] + let s1: TreeSet = [a, b] + let s2: TreeSet = [a, c] expectEqualSets(s0.intersection(s0), []) expectEqualSets(s1.intersection(s0), []) @@ -181,8 +181,8 @@ class ShareableSetTests: CollectionTestCase { let ab = RawCollider(4, "AB") let ac = RawCollider(5, "AC") - let s3: ShareableSet = [ab, ac] - let s4: ShareableSet = [a, ab] + let s3: TreeSet = [ab, ac] + let s4: TreeSet = [a, ab] expectEqualSets(s1.intersection(s3), []) expectEqualSets(s2.intersection(s3), []) expectEqualSets(s1.intersection(s4), [a]) @@ -194,7 +194,7 @@ class ShareableSetTests: CollectionTestCase { let ad = RawCollider(6, "AD") let ae = RawCollider(7, "AE") - let s5: ShareableSet = [a, ab, ad, ae] + let s5: TreeSet = [a, ab, ad, ae] expectEqualSets(s1.intersection(s5), [a]) expectEqualSets(s2.intersection(s5), [a]) expectEqualSets(s3.intersection(s5), [ab]) @@ -207,7 +207,7 @@ class ShareableSetTests: CollectionTestCase { let af1 = RawCollider(8, "AF") let af2 = RawCollider(9, "AF") - let s6: ShareableSet = [af1, af2] + let s6: TreeSet = [af1, af2] expectEqualSets(s1.intersection(s6), []) expectEqualSets(s2.intersection(s6), []) expectEqualSets(s3.intersection(s6), []) @@ -221,7 +221,7 @@ class ShareableSetTests: CollectionTestCase { expectEqualSets(s6.intersection(s5), []) let af3 = RawCollider(10, "AF") - let s7: ShareableSet = [af1, af3] + let s7: TreeSet = [af1, af3] expectEqualSets(s1.intersection(s7), []) expectEqualSets(s2.intersection(s7), []) expectEqualSets(s3.intersection(s7), []) @@ -236,7 +236,7 @@ class ShareableSetTests: CollectionTestCase { expectEqualSets(s7.intersection(s5), []) expectEqualSets(s7.intersection(s6), [af1]) - let s8: ShareableSet = [a, af1] + let s8: TreeSet = [a, af1] expectEqualSets(s1.intersection(s8), [a]) expectEqualSets(s2.intersection(s8), [a]) expectEqualSets(s3.intersection(s8), []) @@ -255,25 +255,25 @@ class ShareableSetTests: CollectionTestCase { let afa1 = RawCollider(11, "AFA") let afa2 = RawCollider(12, "AFA") - let s9: ShareableSet = [afa1, afa2] + let s9: TreeSet = [afa1, afa2] expectEqualSets(s9.intersection(s6), []) expectEqualSets(s6.intersection(s9), []) } func test_isEqual_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectTrue(x.isEqualSet(to: x)) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = (u == v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S ) -> Bool where S.Element == RawCollider { @@ -292,18 +292,18 @@ class ShareableSetTests: CollectionTestCase { func test_isSubset_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectTrue(x.isSubset(of: x)) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.isSubset(of: v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S ) -> Bool where S.Element == RawCollider { @@ -322,18 +322,18 @@ class ShareableSetTests: CollectionTestCase { func test_isSuperset_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectTrue(x.isSuperset(of: x)) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.isSuperset(of: v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S ) -> Bool where S.Element == RawCollider { @@ -352,18 +352,18 @@ class ShareableSetTests: CollectionTestCase { func test_isStrictSubset_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectFalse(x.isStrictSubset(of: x)) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.isStrictSubset(of: v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S ) -> Bool where S.Element == RawCollider { @@ -382,18 +382,18 @@ class ShareableSetTests: CollectionTestCase { func test_isStrictSuperset_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectFalse(x.isStrictSuperset(of: x)) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.isStrictSuperset(of: v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S ) -> Bool where S.Element == RawCollider { @@ -412,17 +412,17 @@ class ShareableSetTests: CollectionTestCase { func test_isDisjoint_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectEqual(x.isDisjoint(with: x), x.isEmpty) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.isDisjoint(with: v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S ) -> Bool where S.Element == RawCollider { @@ -441,20 +441,20 @@ class ShareableSetTests: CollectionTestCase { func test_intersection_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectEqualSets(x.intersection(x), u) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.intersection(v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S - ) -> ShareableSet + ) -> TreeSet where S.Element == RawCollider { a.intersection(b) } @@ -471,20 +471,20 @@ class ShareableSetTests: CollectionTestCase { func test_subtracting_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectEqualSets(x.subtracting(x), []) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.subtracting(v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S - ) -> ShareableSet + ) -> TreeSet where S.Element == RawCollider { a.subtracting(b) } @@ -501,7 +501,7 @@ class ShareableSetTests: CollectionTestCase { func test_filter_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) withEverySubset("b", of: a) { b in let v = Set(b) expectEqualSets(x.filter { v.contains($0) }, v) @@ -513,7 +513,7 @@ class ShareableSetTests: CollectionTestCase { withEvery("isShared", in: [false, true]) { isShared in withEverySubset("a", of: testItems) { a in withEverySubset("b", of: a) { b in - var x = ShareableSet(a) + var x = TreeSet(a) let v = Set(b) withHiddenCopies(if: isShared, of: &x) { x in x.removeAll { !v.contains($0) } @@ -526,20 +526,20 @@ class ShareableSetTests: CollectionTestCase { func test_union_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectEqualSets(x.union(x), u) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.union(v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S - ) -> ShareableSet + ) -> TreeSet where S.Element == RawCollider { a.union(b) } @@ -556,20 +556,20 @@ class ShareableSetTests: CollectionTestCase { func test_symmetricDifference_exhaustive() { withEverySubset("a", of: testItems) { a in - let x = ShareableSet(a) + let x = TreeSet(a) let u = Set(a) expectEqualSets(x.symmetricDifference(x), []) withEverySubset("b", of: testItems) { b in - let y = ShareableSet(b) + let y = TreeSet(b) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) let reference = u.symmetricDifference(v) func checkSequence( - _ a: ShareableSet, + _ a: TreeSet, _ b: S - ) -> ShareableSet + ) -> TreeSet where S.Element == RawCollider { a.symmetricDifference(b) } @@ -588,15 +588,15 @@ class ShareableSetTests: CollectionTestCase { let a = [1, 2, 3, 4] let b = [0, 2, 4, 6] - let x = ShareableSet(a) - let y = ShareableSet(b) + let x = TreeSet(a) + let y = TreeSet(b) let u = Set(a) let v = Set(b) - let z = ShareableDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) + let z = TreeDictionary(uniqueKeysWithValues: b.map { ($0, $0) }) func check( _ reference: Set, - _ body: (inout ShareableSet) -> Void, + _ body: (inout TreeSet) -> Void, file: StaticString = #file, line: UInt = #line ) { @@ -643,7 +643,7 @@ class ShareableSetTests: CollectionTestCase { withEvery("offset", in: 0 ..< a.count) { offset in withEvery("isShared", in: [false, true]) { isShared in withLifetimeTracking { tracker in - var x = ShareableSet(tracker.instances(for: a)) + var x = TreeSet(tracker.instances(for: a)) let i = x.firstIndex { $0.payload == a[offset] }! let replacement = tracker.instance(for: a[offset]) withHiddenCopies(if: isShared, of: &x) { x in @@ -658,7 +658,7 @@ class ShareableSetTests: CollectionTestCase { } func test_Hashable() { - let classes: [[ShareableSet]] = [ + let classes: [[TreeSet]] = [ [ [] ], @@ -698,43 +698,43 @@ class ShareableSetTests: CollectionTestCase { } func test_Codable() throws { - let s1: ShareableSet = [] + let s1: TreeSet = [] let v1: MinimalEncoder.Value = .array([]) expectEqual(try MinimalEncoder.encode(s1), v1) - let s2: ShareableSet = [3] + let s2: TreeSet = [3] let v2: MinimalEncoder.Value = .array([.int(3)]) expectEqual(try MinimalEncoder.encode(s2), v2) - let s3: ShareableSet = [0, 1, 2, 3] + let s3: TreeSet = [0, 1, 2, 3] let v3: MinimalEncoder.Value = .array(s3.map { .int($0) }) expectEqual(try MinimalEncoder.encode(s3), v3) - let s4 = ShareableSet(0 ..< 100) + let s4 = TreeSet(0 ..< 100) let v4: MinimalEncoder.Value = .array(s4.map { .int($0) }) expectEqual(try MinimalEncoder.encode(s4), v4) } func test_Decodable() throws { - let s1: ShareableSet = [] + let s1: TreeSet = [] let v1: MinimalEncoder.Value = .array([]) - expectEqual(try MinimalDecoder.decode(v1, as: ShareableSet.self), s1) + expectEqual(try MinimalDecoder.decode(v1, as: TreeSet.self), s1) - let s2: ShareableSet = [3] + let s2: TreeSet = [3] let v2: MinimalEncoder.Value = .array([.int(3)]) - expectEqual(try MinimalDecoder.decode(v2, as: ShareableSet.self), s2) + expectEqual(try MinimalDecoder.decode(v2, as: TreeSet.self), s2) - let s3: ShareableSet = [0, 1, 2, 3] + let s3: TreeSet = [0, 1, 2, 3] let v3: MinimalEncoder.Value = .array([.int(0), .int(1), .int(2), .int(3)]) - expectEqual(try MinimalDecoder.decode(v3, as: ShareableSet.self), s3) + expectEqual(try MinimalDecoder.decode(v3, as: TreeSet.self), s3) - let s4 = ShareableSet(0 ..< 100) + let s4 = TreeSet(0 ..< 100) let v4: MinimalEncoder.Value = .array((0 ..< 100).map { .int($0) }) - expectEqual(try MinimalDecoder.decode(v4, as: ShareableSet.self), s4) + expectEqual(try MinimalDecoder.decode(v4, as: TreeSet.self), s4) let v5: MinimalEncoder.Value = .array([.int(0), .int(1), .int(0)]) expectThrows( - try MinimalDecoder.decode(v5, as: ShareableSet.self) + try MinimalDecoder.decode(v5, as: TreeSet.self) ) { error in expectNotNil(error as? DecodingError) { error in guard case .dataCorrupted(let context) = error else { @@ -748,7 +748,7 @@ class ShareableSetTests: CollectionTestCase { let v6: MinimalEncoder.Value = .array([.int16(42)]) expectThrows( - try MinimalDecoder.decode(v6, as: ShareableSet.self) + try MinimalDecoder.decode(v6, as: TreeSet.self) ) { error in expectNotNil(error as? DecodingError) { error in guard case .typeMismatch(_, _) = error else { @@ -760,7 +760,7 @@ class ShareableSetTests: CollectionTestCase { } func test_CustomReflectable() { - let s: ShareableSet = [0, 1, 2, 3] + let s: TreeSet = [0, 1, 2, 3] let mirror = Mirror(reflecting: s) expectEqual(mirror.displayStyle, .set) expectNil(mirror.superclassMirror) diff --git a/Tests/ShareableHashedCollectionsTests/Utilities.swift b/Tests/HashTreeCollectionsTests/Utilities.swift similarity index 91% rename from Tests/ShareableHashedCollectionsTests/Utilities.swift rename to Tests/HashTreeCollectionsTests/Utilities.swift index 296b8187..2e2591a3 100644 --- a/Tests/ShareableHashedCollectionsTests/Utilities.swift +++ b/Tests/HashTreeCollectionsTests/Utilities.swift @@ -10,13 +10,13 @@ //===----------------------------------------------------------------------===// import _CollectionsTestSupport -import ShareableHashedCollections +import HashTreeCollections extension LifetimeTracker { func shareableDictionary( keys: Keys ) -> ( - dictionary: ShareableDictionary, LifetimeTracked>, + dictionary: TreeDictionary, LifetimeTracked>, keys: [LifetimeTracked], values: [LifetimeTracked] ) @@ -25,7 +25,7 @@ extension LifetimeTracker { let k = Array(keys) let keys = self.instances(for: k) let values = self.instances(for: k.map { $0 + 100 }) - let dictionary = ShareableDictionary( + let dictionary = TreeDictionary( uniqueKeysWithValues: zip(keys, values)) return (dictionary, keys, values) } @@ -84,7 +84,7 @@ extension LifetimeTracker { _ payloads: Payloads, with generator: G ) -> ( - map: ShareableDictionary, LifetimeTracked>, + map: TreeDictionary, LifetimeTracked>, expected: [LifetimeTracked: LifetimeTracked] ) where Payloads.Element == Int @@ -97,7 +97,7 @@ extension LifetimeTracker { instance(for: generator.value(for: $0))) } } - let map = ShareableDictionary(uniqueKeysWithValues: gen()) + let map = TreeDictionary(uniqueKeysWithValues: gen()) let expected = Dictionary(uniqueKeysWithValues: gen()) return (map, expected) } @@ -105,7 +105,7 @@ extension LifetimeTracker { func shareableDictionary( keys: Keys ) -> ( - map: ShareableDictionary, LifetimeTracked>, + map: TreeDictionary, LifetimeTracked>, expected: [LifetimeTracked: LifetimeTracked] ) where Keys.Element == Int @@ -131,7 +131,7 @@ func _expectFailure( } func expectEqualSets( - _ set: ShareableSet, + _ set: TreeSet, _ ref: [Element], _ message: @autoclosure () -> String = "", trapping: Bool = false, @@ -184,7 +184,7 @@ func expectEqualSets( func expectEqualDictionaries( - _ map: ShareableDictionary, + _ map: TreeDictionary, _ ref: [(key: Key, value: Value)], _ message: @autoclosure () -> String = "", trapping: Bool = false, @@ -199,7 +199,7 @@ func expectEqualDictionaries( } func expectEqualDictionaries( - _ map: ShareableDictionary, + _ map: TreeDictionary, _ dict: Dictionary, _ message: @autoclosure () -> String = "", trapping: Bool = false, diff --git a/Utils/generate-docs.sh b/Utils/generate-docs.sh index 0f8bd669..d0559ab6 100755 --- a/Utils/generate-docs.sh +++ b/Utils/generate-docs.sh @@ -31,7 +31,7 @@ rm -rf "$output_dir_base" components="\ BitCollections DequeModule HeapModule OrderedCollections \ - ShareableHashedCollections" + HashTreeCollections" if [ $# -eq 0 ]; then targets="Collections $components" diff --git a/Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/ShareableHashedCollections.xcscheme b/Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/HashTreeCollections.xcscheme similarity index 65% rename from Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/ShareableHashedCollections.xcscheme rename to Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/HashTreeCollections.xcscheme index df107a2c..35631f44 100644 --- a/Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/ShareableHashedCollections.xcscheme +++ b/Utils/swift-collections.xcworkspace/xcshareddata/xcschemes/HashTreeCollections.xcscheme @@ -1,6 +1,6 @@ - - - - @@ -41,16 +27,15 @@ selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" shouldUseLaunchSchemeArgsEnv = "YES" - enableASanStackUseAfterReturn = "YES" codeCoverageEnabled = "YES"> @@ -76,9 +61,9 @@