Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent collections updates (part 3) #176

Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,15 @@ let package = Package(
dependencies: ["_CollectionsTestSupport"],
swiftSettings: settings),

.target(
name: "_CollectionsUtilities",
exclude: ["CMakeLists.txt"],
swiftSettings: settings),

// Deque<Element>
.target(
name: "DequeModule",
dependencies: ["_CollectionsUtilities"],
exclude: ["CMakeLists.txt"],
swiftSettings: settings),
.testTarget(
Expand All @@ -99,6 +105,7 @@ let package = Package(
// OrderedSet<Element>, OrderedDictionary<Key, Value>
.target(
name: "OrderedCollections",
dependencies: ["_CollectionsUtilities"],
exclude: ["CMakeLists.txt"],
swiftSettings: settings),
.testTarget(
Expand All @@ -109,6 +116,7 @@ let package = Package(
// PersistentDictionary<Key, Value>
.target(
name: "PersistentCollections",
dependencies: ["_CollectionsUtilities"],
swiftSettings: settings),
.testTarget(
name: "PersistentCollectionsTests",
Expand Down
28 changes: 0 additions & 28 deletions Sources/DequeModule/Deque+CustomStringConvertible.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,18 @@
//
//===----------------------------------------------------------------------===//

import _CollectionsUtilities

extension Deque: CustomStringConvertible {
/// A textual representation of this instance.
public var description: String {
_arrayDescription(for: self)
}
}

extension Deque: CustomDebugStringConvertible {
/// A textual representation of this instance, suitable for debugging.
public var debugDescription: String {
var result = "Deque<\(Element.self)>(["
var first = true
for item in self {
if first {
first = false
} else {
result += ", "
}
debugPrint(item, terminator: "", to: &result)
}
result += "])"
return result
_arrayDescription(for: self, typeName: "Deque<\(Element.self)>")
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,43 +2,29 @@
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2021 Apple Inc. and the Swift project authors
// Copyright (c) 2021 - 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
//
//===----------------------------------------------------------------------===//

import _CollectionsUtilities

extension OrderedDictionary: CustomStringConvertible {
/// A textual representation of this instance.
public var description: String {
_dictionaryDescription(for: self.elements)
}
}

extension OrderedDictionary: CustomDebugStringConvertible {
/// A textual representation of this instance, suitable for debugging.
public var debugDescription: String {
_debugDescription(typeName: _debugTypeName())
_dictionaryDescription(for: self.elements, typeName: _debugTypeName())
}

internal func _debugTypeName() -> String {
"OrderedDictionary<\(Key.self), \(Value.self)>"
}

internal func _debugDescription(typeName: String) -> String {
var result = "\(typeName)("
if isEmpty {
result += "[:]"
} else {
result += "["
var first = true
for (key, value) in self {
if first {
first = false
} else {
result += ", "
}
debugPrint(key, terminator: "", to: &result)
result += ": "
debugPrint(value, terminator: "", to: &result)
}
result += "]"
}
result += ")"
return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//
//===----------------------------------------------------------------------===//

import _CollectionsUtilities

extension OrderedDictionary {
/// A view of the contents of an ordered dictionary as a random-access
/// collection.
Expand Down Expand Up @@ -333,7 +335,8 @@ extension OrderedDictionary.Elements: CustomStringConvertible {

extension OrderedDictionary.Elements: CustomDebugStringConvertible {
public var debugDescription: String {
_base._debugDescription(
_dictionaryDescription(
for: self,
typeName: "OrderedDictionary<\(Key.self), \(Value.self)>.Elements")
}
}
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,29 @@
//
// This source file is part of the Swift Collections open source project
//
// Copyright (c) 2021 Apple Inc. and the Swift project authors
// Copyright (c) 2021 - 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
//
//===----------------------------------------------------------------------===//

import _CollectionsUtilities

extension OrderedSet: CustomStringConvertible {
/// A textual representation of this instance.
public var description: String {
_arrayDescription(for: self)
}
}

extension OrderedSet: CustomDebugStringConvertible {
/// A textual representation of this instance, suitable for debugging.
public var debugDescription: String {
_debugDescription(typeName: _debugTypeName())
_arrayDescription(for: self, typeName: _debugTypeName())
}

internal func _debugTypeName() -> String {
"OrderedSet<\(Element.self)>"
}

internal func _debugDescription(typeName: String) -> String {
var result = "\(typeName)(["
var first = true
for item in self {
if first {
first = false
} else {
result += ", "
}
debugPrint(item, terminator: "", to: &result)
}
result += "])"
return result
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
//
//===----------------------------------------------------------------------===//

import _CollectionsUtilities

extension OrderedSet {
/// An unordered view into an ordered set, providing `SetAlgebra`
/// conformance.
Expand Down Expand Up @@ -72,7 +74,9 @@ extension OrderedSet.UnorderedView: CustomStringConvertible {
extension OrderedSet.UnorderedView: CustomDebugStringConvertible {
/// A textual representation of this instance, suitable for debugging.
public var debugDescription: String {
_base._debugDescription(typeName: "\(_base._debugTypeName()).UnorderedView")
_arrayDescription(
for: _base,
typeName: "\(_base._debugTypeName()).UnorderedView")
}
}

Expand Down
Loading