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

[SS-005] Migration to SPM #6

Merged
merged 4 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
29 changes: 29 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// swift-tools-version: 5.10
// The swift-tools-version declares the minimum version of Swift required to build this package.

import PackageDescription

let package = Package(
name: "YeongKit",
platforms: [
.iOS(.v15),
.macOS(.v10_15)
],
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "YeongKit",
targets: ["SwiftStructures"]),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(name: "SwiftStructures"),

.testTarget(
name: "SwiftStructuresTests",
dependencies: [
"SwiftStructures"
]),
]
)
2 changes: 1 addition & 1 deletion Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ If the count exceeds the number of key-value pairs in the dictionary, it will be
### LockedDictionary

LockedDictionary is a custom thread-safe wrapper around Swift’s native Dictionary. It ensures safe, concurrent access to its elements by using a lock (NSLock). This class is particularly useful in multithreaded environments where concurrent reads and writes to a dictionary could lead to data races or inconsistencies.

#### Example

```swift
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ public class HashMap<Key, Value> where Key: Hashable & Comparable {

private let lock: NSLock = .init()

public init() { }

public subscript(key: Key) -> Value? {
get {
defer {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import Foundation
/// - All values in the tree must be unique. Attempting to insert a duplicate value will result in an error.
public class RBTree<Element> where Element: Comparable {

typealias Node = RBTreeNode<Element>
public typealias Node = RBTreeNode<Element>

private(set) var rootNode: Node?

Expand Down Expand Up @@ -115,7 +115,7 @@ public extension RBTree {


// MARK: Find node
extension RBTree {
public extension RBTree {

func findNode(_ value: Element) -> Node? {

Expand Down Expand Up @@ -591,8 +591,15 @@ public extension RBTree {
// MARK: for test
extension RBTree where Element == Int {


func printTree() {
/**
You can print your tree.
Printed node consists of 3 components:

- `color`: 🟥 or ⬛️
- `p`: parent node's value
- `v`: node's value
*/
public func printTree() {

var printLayer: [Int: [RBTreeNode<Int>]] = [0: [rootNode!]]

Expand Down
Binary file removed SwiftStructures/.DS_Store
Binary file not shown.
Loading