Last active
September 29, 2018 12:21
-
-
Save GuanshanLiu/74bee8d62c8838783599e3578c9fd13d to your computer and use it in GitHub Desktop.
This file contains 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
public var isEmpty: Bool { | |
return elements.isEmpty | |
} | |
public var count: Int { | |
return elements.count | |
} | |
public func leftChildIndex(forParentAt index: Int) -> Int { | |
return 2 * index + 1 | |
} | |
public func rightChildIndex(forParentAt index: Int) -> Int { | |
return 2 * index + 2 | |
} | |
public func parentIndex(forChildAt index: Int) -> Int { | |
return (index - 1) / 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment