88
99import Foundation
1010
11- class SynchronizedDictionaryComposed < K: Hashable , IK: Hashable > : @unchecked Sendable {
11+ public class SynchronizedDictionaryComposed < K: Hashable , IK: Hashable > : @unchecked Sendable {
1212
1313 private var queue : DispatchQueue = DispatchQueue ( label: " split-synchronized-dictionary-composed " ,
1414 target: . global( ) )
1515 private var items = [ K: [ IK: Any] ] ( )
1616
17- func count( forKey key: K ) -> Int {
17+ public init ( ) { }
18+
19+ public func count( forKey key: K ) -> Int {
1820 var count : Int ?
1921 queue. sync {
2022 count = items [ key] ? . count
2123 }
2224 return count ?? 0
2325 }
2426
25- func values( forKey key: K ) -> [ IK : Any ] ? {
27+ public func values( forKey key: K ) -> [ IK : Any ] ? {
2628 var value : [ IK : Any ] ?
2729 queue. sync {
2830 value = items [ key]
2931 }
3032 return value
3133 }
3234
33- func value( _ innerKey: IK , forKey key: K ) -> Any ? {
35+ public func value( _ innerKey: IK , forKey key: K ) -> Any ? {
3436 var value : Any ?
3537 queue. sync {
3638 value = items [ key] ? [ innerKey]
3739 }
3840 return value
3941 }
4042
41- func contains( innerKey: IK , forKey key: K ) -> Bool {
43+ public func contains( innerKey: IK , forKey key: K ) -> Bool {
4244 var hasValue : Bool ?
4345 queue. sync {
4446 hasValue = items [ key] ? . keys. contains ( innerKey)
4547 }
4648 return hasValue ?? false
4749 }
4850
49- func set( _ values: [ IK : Any ] , forKey key: K ) {
51+ public func set( _ values: [ IK : Any ] , forKey key: K ) {
5052 queue. sync {
5153 self . items [ key] = values
5254 }
5355 }
5456
55- func set( _ value: Any , forInnerKey innerKey: IK , forKey key: K ) {
57+ public func set( _ value: Any , forInnerKey innerKey: IK , forKey key: K ) {
5658 queue. sync {
5759 var values = self . items [ key] ?? [ : ]
5860 values [ innerKey] = value
5961 self . items [ key] = values
6062 }
6163 }
6264
63- func putValues( _ values: [ IK : Any ] , forKey key: K ) {
65+ public func putValues( _ values: [ IK : Any ] , forKey key: K ) {
6466 queue. sync {
6567 var newValues = self . items [ key] ?? [ : ]
6668 for (innerKey, value) in values {
@@ -70,19 +72,19 @@ class SynchronizedDictionaryComposed<K: Hashable, IK: Hashable>: @unchecked Send
7072 }
7173 }
7274
73- func removeValue( _ innerKey: IK , forKey key: K ) {
75+ public func removeValue( _ innerKey: IK , forKey key: K ) {
7476 queue. sync {
7577 _ = self . items [ key] ? . removeValue ( forKey: innerKey)
7678 }
7779 }
7880
79- func removeValues( forKey key: K ) {
81+ public func removeValues( forKey key: K ) {
8082 queue. sync {
8183 _ = self . items. removeValue ( forKey: key)
8284 }
8385 }
8486
85- func removeAll( ) {
87+ public func removeAll( ) {
8688 queue. sync {
8789 self . items. removeAll ( )
8890 }
0 commit comments