Comments (21)
private enum RBTreeColor {
case red
case black
}
枚举
from dsa.
public class RBTreeNode<T: Comparable>: Equatable { }
from dsa.
public convenience init(key: T?) {
self.init(key: key, leftChild: RBNode(), rightChild: RBNode(), parent: RBNode())
}
public init(key: T?, leftChild: RBNode?, rightChild: RBNode?, parent: RBNode?) { }
from dsa.
var isLeaf: Bool {
return rightChild == nil && leftChild == nil
}
不是函数哈
from dsa.
var isLeaf: Bool {
return rightChild == nil && leftChild == nil
}
from dsa.
fileprivate(set) var root: RBNode
from dsa.
extension RBTreeNode {
static public func == (lhs: RBTreeNode, rhs: RBTreeNode) -> Bool {
return lhs.key == rhs.key
}
}
from dsa.
if let leftChild = leftChild, !leftChild.isNullLeaf {
return leftChild.maximum()
}
from dsa.
// If node nil -> key not found
guard let node = node else {
return nil
}
guard let inputKey = input.key, let nodeKey = node.key else {
return
}
from dsa.
// MARK: - Inserting new nodes
from dsa.
extension RBTreeNode: CustomStringConvertible {
public var description: String {
var s = ""
if isNullLeaf {
s += "nullLeaf"
} else {
if let left = leftChild {
s += "((left.description)) <- "
}
return s
}
}
from dsa.
extension TreeNode where T: Equatable { }
from dsa.
private func insert(_ key: KeyType, val: Any) { }
from dsa.
private var cache: [KeyType: Any] = [:]
from dsa.
public mutating func sort() -> [T] {}
from dsa.
private var orderCriteria: (T, T) -> Bool
/**
- Creates an empty heap.
- The sort function determines whether this is a min-heap or max-heap.
- For comparable data types, > makes a max-heap, < makes a min-heap.
*/
public init(sort: @escaping (T, T) -> Bool) {
self.orderCriteria = sort
}
from dsa.
@inline(__always) internal func parentIndex(ofIndex i: Int) -> Int {
return (i - 1) / 2
}
from dsa.
public mutating func insert<S: Sequence>(_ sequence: S) where S.Iterator.Element == T {
for value in sequence {
insert(value)
}
}
from dsa.
@discardableResult public mutating func remove() -> T? { }
from dsa.
var h1 = Heap(array: [5, 13, 2, 25, 7, 17, 20, 8, 4], sort: >)
from dsa.
func partitionDutchFlag<T: Comparable>(_ a: inout [T], low: Int, high: Int, pivotIndex: Int) -> (Int, Int) {
from dsa.
Related Issues (20)
- SingIeton
- State
- Strategy
- Template Method
- Visitor
- Code1:"1965-07-31T00:00:00+0000"时间转换
- 深入iOS需要掌握的技术点
- Git 命令
- iOS小集 HOT 1
- PHP学习路线 HOT 1
- 前端学习路线 HOT 42
- 苹果内购被拒case HOT 8
- C++容器 http://www.cplusplus.com/reference HOT 12
- 程序设计
- UML 图
- 数据结构和算法
- git reset
- 微信
- 设计师进阶路 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dsa.