上一页 1 2 3 4 5 6 ··· 30 下一页

2019年3月31日

摘要: 参数类型是Constant Pointer也就是 UnsafePointer 可以传入的类型: UnsafePointer/UnsafeMutablePointer/AutoreleasingUnsafeMutablePointerString。如果Type 是 UInt8 或 Int8。可变类型的 Type 的 in-out 类型。[Type] 类型,被当作指向第一个元素的地址例子如下: f... 阅读全文
posted @ 2019-03-31 09:01 花老🐯 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 指向类的指针class PointerTestClass { var intNum = 3 var another = 56 var another1 = 59}下面是验证代码let pointer: UnsafeMutablePointer = UnsafeMutablePointer.allocate(capacity: 3)let testInstance = Pointe... 阅读全文
posted @ 2019-03-31 09:00 花老🐯 阅读(188) 评论(0) 推荐(0) 编辑
摘要: 基础知识指针的内存状态typed?initiated?❌❌✅❌✅✅之前分配的内存可能被释放,使得指针指向了未被分配的内存。有两种方式可以使得指针指向的内存处于Uninitialized状态:刚刚被分配内存内存被deinitializedvar bytes: [UInt8] = [39, 77, 111, 111, 102, 33, 39, 0]let uint8Pointer = UnsafeM... 阅读全文
posted @ 2019-03-31 09:00 花老🐯 阅读(163) 评论(0) 推荐(0) 编辑

2019年3月24日

摘要: Dictionary uses two storage schemes: native storage and Cocoa storage. 只看 native storage 的,也就是和 OC 无关的。类图 内存分布分配内存的地方: static internal func allocate( scale: Int8, age: Int32?, seed: Int... 阅读全文
posted @ 2019-03-24 13:57 花老🐯 阅读(268) 评论(0) 推荐(0) 编辑
摘要: Adding Elements internal func _unsafeInsertNew(_ element: __owned Element) { _internalInvariant(count + 1 Bool { if _fastPath(capacity Element { _internalInvariant(hashTable.isOccupied(buc... 阅读全文
posted @ 2019-03-24 13:12 花老🐯 阅读(268) 评论(0) 推荐(0) 编辑
摘要: 即contains操作 /// - Parameter member: An element to look for in the set. /// - Returns: `true` if `member` exists in the set; otherwise, `false`. /// /// - Complexity: O(1) @inlinable public fun... 阅读全文
posted @ 2019-03-24 12:44 花老🐯 阅读(208) 评论(0) 推荐(0) 编辑
摘要: isEmpty /// A Boolean value that indicates whether the set is empty. @inlinable public var isEmpty: Bool { return count == 0 }count /// The number of elements in the set. /// /// - Complexit... 阅读全文
posted @ 2019-03-24 12:19 花老🐯 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 类图Set 是一个结构体,持有另一个结构体_Variant。最终所有的元素存储在一个叫做__RawSetStorage的类里。 内存布局结构体分配在栈上,和__RawSetStorage相关的变量分配在堆里。__RawSetStorage 只有一些基本的属性,比如count、capacity等。在初始化__RawSetStorage时,会在类的尾部继续分配内存,真正的存储Set里的对象。 ... 阅读全文
posted @ 2019-03-24 12:18 花老🐯 阅读(290) 评论(0) 推荐(0) 编辑
摘要: _UnsafeBitset是一个固定大小的 bitmap,用来确定指定位置是否有元素存在。HashTable具体的 hash 碰撞算法在HashTable里实现,目前使用的是简单的开放地址法,使用算法是Linear probing。 HashTable 的属性其实只有若干个 UInt,每一位用来表示状态,指定位置有没有被占用。 @usableFromInline internal v... 阅读全文
posted @ 2019-03-24 11:06 花老🐯 阅读(322) 评论(0) 推荐(0) 编辑

2019年3月22日

摘要: 根据下标取值关键代码如下: func _getElement( _ index: Int, wasNativeTypeChecked: Bool, matchingSubscriptCheck: _DependenceToken ) -> Element {#if _runtime(_ObjC) return _buffer.getElement(index, wasN... 阅读全文
posted @ 2019-03-22 00:50 花老🐯 阅读(237) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 ··· 30 下一页

导航