File tree Expand file tree Collapse file tree 1 file changed +5
-5
lines changed
Multiset/Multiset.playground/Sources Expand file tree Collapse file tree 1 file changed +5
-5
lines changed Original file line number Diff line number Diff line change 8
8
import Foundation
9
9
10
10
public struct Multiset < Element: Hashable > {
11
- fileprivate var storage : [ Element : Int ]
12
- private var _count = 0
11
+ fileprivate var storage : [ Element : UInt ]
12
+ private var _count : UInt = 0
13
13
14
14
public init ( ) {
15
15
storage = [ : ]
@@ -45,16 +45,16 @@ public struct Multiset<Element: Hashable> {
45
45
return true
46
46
}
47
47
48
- public var count : Int {
48
+ public var count : UInt {
49
49
return _count
50
50
}
51
51
52
- public func count( for key: Element ) -> Int {
52
+ public func count( for key: Element ) -> UInt {
53
53
return storage [ key] ?? 0
54
54
}
55
55
56
56
public var allItems : [ Element ] {
57
- var result = Array < Element > ( )
57
+ var result = [ Element] ( )
58
58
for (key, count) in storage {
59
59
for _ in 0 ..< count {
60
60
result. append ( key)
You can’t perform that action at this time.
0 commit comments