Code Monkey home page Code Monkey logo

Comments (21)

lefex avatar lefex commented on June 21, 2024

private enum RBTreeColor {
case red
case black
}

枚举

from dsa.

lefex avatar lefex commented on June 21, 2024

public class RBTreeNode<T: Comparable>: Equatable { }

from dsa.

lefex avatar lefex commented on June 21, 2024

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.

lefex avatar lefex commented on June 21, 2024

var isLeaf: Bool {
return rightChild == nil && leftChild == nil
}
不是函数哈

from dsa.

lefex avatar lefex commented on June 21, 2024

var isLeaf: Bool {
return rightChild == nil && leftChild == nil
}

from dsa.

lefex avatar lefex commented on June 21, 2024

fileprivate(set) var root: RBNode

from dsa.

lefex avatar lefex commented on June 21, 2024

extension RBTreeNode {
static public func == (lhs: RBTreeNode, rhs: RBTreeNode) -> Bool {
return lhs.key == rhs.key
}
}

from dsa.

lefex avatar lefex commented on June 21, 2024

if let leftChild = leftChild, !leftChild.isNullLeaf {
return leftChild.maximum()
}

from dsa.

lefex avatar lefex commented on June 21, 2024

// 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.

lefex avatar lefex commented on June 21, 2024

// MARK: - Inserting new nodes

from dsa.

lefex avatar lefex commented on June 21, 2024

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.

lefex avatar lefex commented on June 21, 2024

extension TreeNode where T: Equatable { }

from dsa.

lefex avatar lefex commented on June 21, 2024

private func insert(_ key: KeyType, val: Any) { }

from dsa.

lefex avatar lefex commented on June 21, 2024

private var cache: [KeyType: Any] = [:]

from dsa.

lefex avatar lefex commented on June 21, 2024

public mutating func sort() -> [T] {}

from dsa.

lefex avatar lefex commented on June 21, 2024

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.

lefex avatar lefex commented on June 21, 2024

@inline(__always) internal func parentIndex(ofIndex i: Int) -> Int {
return (i - 1) / 2
}

from dsa.

lefex avatar lefex commented on June 21, 2024

public mutating func insert<S: Sequence>(_ sequence: S) where S.Iterator.Element == T {
for value in sequence {
insert(value)
}
}

from dsa.

lefex avatar lefex commented on June 21, 2024

@discardableResult public mutating func remove() -> T? { }

from dsa.

lefex avatar lefex commented on June 21, 2024

var h1 = Heap(array: [5, 13, 2, 25, 7, 17, 20, 8, 4], sort: >)

from dsa.

lefex avatar lefex commented on June 21, 2024

func partitionDutchFlag<T: Comparable>(_ a: inout [T], low: Int, high: Int, pivotIndex: Int) -> (Int, Int) {

from dsa.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.