Skip to content

Commit 948a562

Browse files
committed
Update utilities
1 parent ffccf93 commit 948a562

File tree

5 files changed

+73
-42
lines changed

5 files changed

+73
-42
lines changed

Sources/GateUtilities/Type+Extensions/Array+Extensions.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
* Copyright © 2025 Dustin Collins (Strega's Gate)
3+
* All Rights Reserved.
4+
*
5+
* http://stregasgate.com
6+
*/
7+
8+
public extension BinaryInteger {
9+
/// The representation of this integer as a padded binary string `0b00000101`
10+
var binaryDescription: String {
11+
let string = String(self, radix: 2)
12+
let padding = String(repeating: "0", count: self.bitWidth - string.count)
13+
return "0b" + padding + string
14+
}
15+
16+
/// The representation of this integer as a padded hex string `0x00FF`
17+
var hexDescription: String {
18+
let string = String(self, radix: 16)
19+
let padding = String(repeating: "0", count: (MemoryLayout<Self>.size * 2) - string.count)
20+
return "0x" + padding + string.uppercased()
21+
}
22+
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/*
2+
* Copyright © 2025 Dustin Collins (Strega's Gate)
3+
* All Rights Reserved.
4+
*
5+
* http://stregasgate.com
6+
*/
7+
8+
public extension Array {
9+
@_transparent
10+
init(minimumCapacity: Int) {
11+
self = []
12+
self.reserveCapacity(minimumCapacity)
13+
}
14+
}
15+
16+
public extension ContiguousArray {
17+
@_transparent
18+
init(minimumCapacity: Int) {
19+
self = []
20+
self.reserveCapacity(minimumCapacity)
21+
}
22+
}
23+
24+
public extension Set {
25+
@_transparent
26+
init(minimumCapacity: Int) {
27+
self = []
28+
self.reserveCapacity(minimumCapacity)
29+
}
30+
}
31+
32+
#if canImport(Collections)
33+
public import Collections
34+
35+
public extension Deque {
36+
@_transparent
37+
init(minimumCapacity: Int) {
38+
self = []
39+
self.reserveCapacity(minimumCapacity)
40+
}
41+
}
42+
43+
public extension OrderedSet {
44+
@_transparent
45+
init(minimumCapacity: Int) {
46+
self = []
47+
self.reserveCapacity(minimumCapacity)
48+
}
49+
}
50+
51+
#endif

Sources/GateUtilities/Type+Extensions/ContiguousArray+Extensions.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

Sources/GateUtilities/Type+Extensions/Set+Extensions.swift

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)