This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename RefCountBits> | |
class RefCounts { | |
std::atomic<RefCountBits> refCounts; | |
void incrementSlow(RefCountBits oldbits, uint32_t inc) SWIFT_CC(PreserveMost); | |
void incrementNonAtomicSlow(RefCountBits oldbits, uint32_t inc); | |
bool tryIncrementSlow(RefCountBits oldbits); | |
bool tryIncrementNonAtomicSlow(RefCountBits oldbits); | |
void incrementUnownedSlow(uint32_t inc); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person { | |
let name: String | |
init(name: String) { self.name = name } | |
var apartment: Apartment? | |
} | |
class Apartment { | |
let unit: String | |
init(unit: String) { self.unit = unit } | |
weak var tenant: Person? | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct HeapObject { | |
/// This is always a valid pointer to a metadata object. | |
HeapMetadata const *metadata; | |
InlineRefCounts refCounts; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct Test { | |
func aMethod() {} | |
} | |
class Test1 { | |
func aMethod() {} | |
} | |
class Test2 { | |
func aMethod() {} | |
} | |
class Test2Subclass: Test2 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let x = 1 | |
let y = 1 | |
let z = x * y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HYAnyIterator<Element>: IteratorProtocol { | |
var hyAnyIteratorHelper: HYAnyIterator<Element>? | |
init<Iter: IteratorProtocol>(_ iter: Iter?) where Iter.Element == Element { | |
if (iter == nil) { | |
return | |
} | |
hyAnyIteratorHelper = HYAnyIteratorHelper(iter) | |
} | |
func next() -> Element? { | |
hyAnyIteratorHelper?.next() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 父层级 | |
struct ContentView : View { | |
@State private var brain: CalculatorBrain = .left("0") | |
var body: some View { | |
// ... | |
CalculatorButtonPad(brain: $brain) | |
.padding(.bottom) | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@propertyWrapper | |
struct Clamping<Value: Comparable> { | |
var value: Value | |
let range: ClosedRange<Value> | |
init(wrappedValue value: Value, _ range: ClosedRange<Value>) { | |
precondition(range.contains(value)) | |
self.value = value | |
self.range = range | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@objcMembers class Person: NSObject { | |
var name: String | |
var age: Int | |
init(name: String, age: Int) { | |
self.name = name | |
self.age = age | |
} | |
} | |
let personArray = [Person(name: "Amy", age: 9), Person(name: "Lily", age: 10), Person(name: "Sam", age: 12), Person(name: "Eric", age: 18)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class LRUCache { | |
let capacity: Int | |
var dict: [Int: Node] = [:] | |
var cache = DoubleList() | |
init(_ capacity: Int) { | |
self.capacity = capacity | |
} |
NewerOlder