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) 编辑

导航